home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Resources / Partition Logic 0.61 / partlogic-0.61.iso / system / headers / sys / api.h next >
C/C++ Source or Header  |  2006-01-31  |  142KB  |  2,918 lines

  1. // 
  2. //  Visopsys
  3. //  Copyright (C) 1998-2006 J. Andrew McLaughlin
  4. //  
  5. //  This library is free software; you can redistribute it and/or modify it
  6. //  under the terms of the GNU Lesser General Public License as published by
  7. //  the Free Software Foundation; either version 2.1 of the License, or (at
  8. //  your option) any later version.
  9. //
  10. //  This library is distributed in the hope that it will be useful, but
  11. //  WITHOUT ANY WARRANTY; without even the implied warranty of
  12. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
  13. //  General Public License for more details.
  14. //
  15. //  You should have received a copy of the GNU Lesser General Public License
  16. //  along with this library; if not, write to the Free Software Foundation,
  17. //  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. //
  19. //  api.h
  20. //
  21.  
  22. // This file describes all of the functions that are directly exported by
  23. // the Visopsys kernel to the outside world.  All functions and their
  24. // numbers are listed here, as well as macros needed to perform call-gate
  25. // calls into the kernel.  Also, each exported kernel function is represented
  26. // here in the form of a little inline function.
  27.  
  28. #if !defined(_API_H)
  29.  
  30. // This file should mostly never be included when we're compiling a kernel
  31. // file (kernelApi.c is an exception)
  32. #if defined(KERNEL)
  33. #error "You cannot call the kernel API from within a kernel function"
  34. #endif
  35.  
  36. #ifndef _X_
  37. #define _X_
  38. #endif
  39.  
  40. #include <time.h>
  41. #include <sys/device.h>
  42. #include <sys/disk.h>
  43. #include <sys/file.h>
  44. #include <sys/image.h>
  45. #include <sys/process.h>
  46. #include <sys/loader.h>
  47. #include <sys/lock.h>
  48. #include <sys/memory.h>
  49. #include <sys/variable.h>
  50. #include <sys/stream.h>
  51. #include <sys/window.h>
  52. #include <sys/network.h>
  53. #include <sys/progress.h>
  54.  
  55. // Included in the Visopsys standard library to prevent API calls from
  56. // within kernel code.
  57. extern int visopsys_in_kernel;
  58.  
  59. // Text input/output functions.  All are in the 1000-1999 range.
  60. #define _fnum_textGetConsoleInput                    1000
  61. #define _fnum_textSetConsoleInput                    1001
  62. #define _fnum_textGetConsoleOutput                   1002
  63. #define _fnum_textSetConsoleOutput                   1003
  64. #define _fnum_textGetCurrentInput                    1004
  65. #define _fnum_textSetCurrentInput                    1005
  66. #define _fnum_textGetCurrentOutput                   1006
  67. #define _fnum_textSetCurrentOutput                   1007
  68. #define _fnum_textGetForeground                      1008
  69. #define _fnum_textSetForeground                      1009
  70. #define _fnum_textGetBackground                      1010
  71. #define _fnum_textSetBackground                      1011
  72. #define _fnum_textPutc                               1012
  73. #define _fnum_textPrint                              1013
  74. #define _fnum_textPrintLine                          1014
  75. #define _fnum_textNewline                            1015
  76. #define _fnum_textBackSpace                          1016
  77. #define _fnum_textTab                                1017
  78. #define _fnum_textCursorUp                           1018
  79. #define _fnum_textCursorDown                         1019
  80. #define _fnum_ternelTextCursorLeft                   1020
  81. #define _fnum_textCursorRight                        1021
  82. #define _fnum_textScroll                             1022
  83. #define _fnum_textGetNumColumns                      1023
  84. #define _fnum_textGetNumRows                         1024
  85. #define _fnum_textGetColumn                          1025
  86. #define _fnum_textSetColumn                          1026
  87. #define _fnum_textGetRow                             1027
  88. #define _fnum_textSetRow                             1028
  89. #define _fnum_textSetCursor                          1029
  90. #define _fnum_textScreenClear                        1030
  91. #define _fnum_textScreenSave                         1031
  92. #define _fnum_textScreenRestore                      1032
  93. #define _fnum_textInputStreamCount                   1033
  94. #define _fnum_textInputCount                         1034
  95. #define _fnum_textInputStreamGetc                    1035
  96. #define _fnum_textInputGetc                          1036
  97. #define _fnum_textInputStreamReadN                   1037
  98. #define _fnum_textInputReadN                         1038
  99. #define _fnum_textInputStreamReadAll                 1039
  100. #define _fnum_textInputReadAll                       1040
  101. #define _fnum_textInputStreamAppend                  1041
  102. #define _fnum_textInputAppend                        1042
  103. #define _fnum_textInputStreamAppendN                 1043
  104. #define _fnum_textInputAppendN                       1044
  105. #define _fnum_textInputStreamRemove                  1045
  106. #define _fnum_textInputRemove                        1046
  107. #define _fnum_textInputStreamRemoveN                 1047
  108. #define _fnum_textInputRemoveN                       1048
  109. #define _fnum_textInputStreamRemoveAll               1049
  110. #define _fnum_textInputRemoveAll                     1050
  111. #define _fnum_textInputStreamSetEcho                 1051
  112. #define _fnum_textInputSetEcho                       1052
  113.  
  114. // Disk functions.  All are in the 2000-2999 range.
  115. #define _fnum_diskReadPartitions                     2000
  116. #define _fnum_diskReadPartitionsAll                  2001
  117. #define _fnum_diskSync                               2002
  118. #define _fnum_diskGetBoot                            2003
  119. #define _fnum_diskGetCount                           2004
  120. #define _fnum_diskGetPhysicalCount                   2005
  121. #define _fnum_diskGet                                2006
  122. #define _fnum_diskGetAll                             2007
  123. #define _fnum_diskGetAllPhysical                     2008
  124. #define _fnum_diskGetPartType                        2009
  125. #define _fnum_diskGetPartTypes                       2010
  126. #define _fnum_diskSetLockState                       2011
  127. #define _fnum_diskSetDoorState                       2012
  128. #define _fnum_diskGetMediaState                      2013
  129. #define _fnum_diskReadSectors                        2014
  130. #define _fnum_diskWriteSectors                       2015
  131. #define _fnum_diskGetFilesystemType                  2016
  132.  
  133. // Filesystem functions.  All are in the 3000-3999 range.
  134. #define _fnum_filesystemFormat                       3000
  135. #define _fnum_filesystemClobber                      3001
  136. #define _fnum_filesystemCheck                        3002
  137. #define _fnum_filesystemDefragment                   3003
  138. #define _fnum_filesystemResizeConstraints            3004
  139. #define _fnum_filesystemResize                       3005
  140. #define _fnum_filesystemMount                        3006
  141. #define _fnum_filesystemUnmount                      3007
  142. #define _fnum_filesystemGetFree                      3008
  143. #define _fnum_filesystemGetBlockSize                 3009
  144.  
  145. // File functions.  All are in the 4000-4999 range.
  146. #define _fnum_fileFixupPath                          4000
  147. #define _fnum_fileSeparateLast                       4001
  148. #define _fnum_fileGetDisk                            4002
  149. #define _fnum_fileCount                              4003
  150. #define _fnum_fileFirst                              4004
  151. #define _fnum_fileNext                               4005
  152. #define _fnum_fileFind                               4006
  153. #define _fnum_fileOpen                               4007
  154. #define _fnum_fileClose                              4008
  155. #define _fnum_fileRead                               4009
  156. #define _fnum_fileWrite                              4010
  157. #define _fnum_fileDelete                             4011
  158. #define _fnum_fileDeleteRecursive                    4012
  159. #define _fnum_fileDeleteSecure                       4013
  160. #define _fnum_fileMakeDir                            4014
  161. #define _fnum_fileRemoveDir                          4015
  162. #define _fnum_fileCopy                               4016
  163. #define _fnum_fileCopyRecursive                      4017
  164. #define _fnum_fileMove                               4018
  165. #define _fnum_fileTimestamp                          4019
  166. #define _fnum_fileGetTemp                            4020
  167. #define _fnum_fileStreamOpen                         4021
  168. #define _fnum_fileStreamSeek                         4022
  169. #define _fnum_fileStreamRead                         4023
  170. #define _fnum_fileStreamReadLine                     4024
  171. #define _fnum_fileStreamWrite                        4025
  172. #define _fnum_fileStreamWriteStr                     4026
  173. #define _fnum_fileStreamWriteLine                    4027
  174. #define _fnum_fileStreamFlush                        4028
  175. #define _fnum_fileStreamClose                        4029
  176.  
  177. // Memory manager functions.  All are in the 5000-5999 range.
  178. #define _fnum_memoryGet                              5000
  179. #define _fnum_memoryGetPhysical                      5001
  180. #define _fnum_memoryRelease                          5002
  181. #define _fnum_memoryReleaseAllByProcId               5003
  182. #define _fnum_memoryChangeOwner                      5004
  183. #define _fnum_memoryGetStats                         5005
  184. #define _fnum_memoryGetBlocks                        5006
  185. #define _fnum_memoryBlockInfo                        5007
  186.  
  187. // Multitasker functions.  All are in the 6000-6999 range.
  188. #define _fnum_multitaskerCreateProcess               6000
  189. #define _fnum_multitaskerSpawn                       6001
  190. #define _fnum_multitaskerGetCurrentProcessId         6002
  191. #define _fnum_multitaskerGetProcess                  6003
  192. #define _fnum_multitaskerGetProcessByName            6004
  193. #define _fnum_multitaskerGetProcesses                6005
  194. #define _fnum_multitaskerSetProcessState             6006
  195. #define _fnum_multitaskerProcessIsAlive              6007
  196. #define _fnum_multitaskerSetProcessPriority          6008
  197. #define _fnum_multitaskerGetProcessPrivilege         6009
  198. #define _fnum_multitaskerGetCurrentDirectory         6010
  199. #define _fnum_multitaskerSetCurrentDirectory         6011
  200. #define _fnum_multitaskerGetTextInput                6012
  201. #define _fnum_multitaskerSetTextInput                6013
  202. #define _fnum_multitaskerGetTextOutput               6014
  203. #define _fnum_multitaskerSetTextOutput               6015
  204. #define _fnum_multitaskerDuplicateIO                 6016
  205. #define _fnum_multitaskerGetProcessorTime            6017
  206. #define _fnum_multitaskerYield                       6018
  207. #define _fnum_multitaskerWait                        6019
  208. #define _fnum_multitaskerBlock                       6020
  209. #define _fnum_multitaskerDetach                      6021
  210. #define _fnum_multitaskerKillProcess                 6022
  211. #define _fnum_multitaskerKillByName                  6023
  212. #define _fnum_multitaskerTerminate                   6024
  213. #define _fnum_multitaskerSignalSet                   6025
  214. #define _fnum_multitaskerSignal                      6026
  215. #define _fnum_multitaskerSignalRead                  6027
  216. #define _fnum_multitaskerGetIOPerm                   6028
  217. #define _fnum_multitaskerSetIOPerm                   6029
  218.  
  219. // Loader functions.  All are in the 7000-7999 range.
  220. #define _fnum_loaderLoad                             7000
  221. #define _fnum_loaderClassify                         7001
  222. #define _fnum_loaderClassifyFile                     7002
  223. #define _fnum_loaderGetSymbols                       7003
  224. #define _fnum_loaderLoadProgram                      7004
  225. #define _fnum_loaderLoadLibrary                      7005
  226. #define _fnum_loaderExecProgram                      7006
  227. #define _fnum_loaderLoadAndExec                      7007
  228.  
  229. // Real-time clock functions.  All are in the 8000-8999 range.
  230. #define _fnum_rtcReadSeconds                         8000
  231. #define _fnum_rtcReadMinutes                         8001
  232. #define _fnum_rtcReadHours                           8002
  233. #define _fnum_rtcDayOfWeek                           8003
  234. #define _fnum_rtcReadDayOfMonth                      8004
  235. #define _fnum_rtcReadMonth                           8005
  236. #define _fnum_rtcReadYear                            8006
  237. #define _fnum_rtcUptimeSeconds                       8007
  238. #define _fnum_rtcDateTime                            8008
  239.  
  240. // Random number functions.  All are in the 9000-9999 range.
  241. #define _fnum_randomUnformatted                      9000
  242. #define _fnum_randomFormatted                        9001
  243. #define _fnum_randomSeededUnformatted                9002
  244. #define _fnum_randomSeededFormatted                  9003
  245.  
  246. // Environment functions.  All are in the 10000-10999 range.
  247. #define _fnum_environmentGet                         10000
  248. #define _fnum_environmentSet                         10001
  249. #define _fnum_environmentUnset                       10002
  250. #define _fnum_environmentDump                        10003
  251.  
  252. // Raw graphics drawing functions.  All are in the 11000-11999 range
  253. #define _fnum_graphicsAreEnabled                     11000
  254. #define _fnum_graphicGetModes                        11001
  255. #define _fnum_graphicGetMode                         11002
  256. #define _fnum_graphicSetMode                         11003
  257. #define _fnum_graphicGetScreenWidth                  11004
  258. #define _fnum_graphicGetScreenHeight                 11005
  259. #define _fnum_graphicCalculateAreaBytes              11006
  260. #define _fnum_graphicClearScreen                     11007
  261. #define _fnum_graphicGetColor                        11008
  262. #define _fnum_graphicSetColor                        11009
  263. #define _fnum_graphicDrawPixel                       11010
  264. #define _fnum_graphicDrawLine                        11011
  265. #define _fnum_graphicDrawRect                        11012
  266. #define _fnum_graphicDrawOval                        11013
  267. #define _fnum_graphicDrawImage                       11014
  268. #define _fnum_graphicGetImage                        11015
  269. #define _fnum_graphicDrawText                        11016
  270. #define _fnum_graphicCopyArea                        11017
  271. #define _fnum_graphicClearArea                       11018
  272. #define _fnum_graphicRenderBuffer                    11019
  273.  
  274. // Windowing system functions.  All are in the 12000-12999 range
  275. #define _fnum_windowLogin                            12000
  276. #define _fnum_windowLogout                           12001
  277. #define _fnum_windowNew                              12002
  278. #define _fnum_windowNewDialog                        12003
  279. #define _fnum_windowDestroy                          12004
  280. #define _fnum_windowUpdateBuffer                     12005
  281. #define _fnum_windowSetTitle                         12006
  282. #define _fnum_windowGetSize                          12007
  283. #define _fnum_windowSetSize                          12008
  284. #define _fnum_windowGetLocation                      12009
  285. #define _fnum_windowSetLocation                      12010
  286. #define _fnum_windowCenter                           12011
  287. #define _fnum_windowSnapIcons                        12012
  288. #define _fnum_windowSetHasBorder                     12013
  289. #define _fnum_windowSetHasTitleBar                   12014
  290. #define _fnum_windowSetMovable                       12015
  291. #define _fnum_windowSetResizable                     12016
  292. #define _fnum_windowSetHasMinimizeButton             12017
  293. #define _fnum_windowSetHasCloseButton                12018
  294. #define _fnum_windowSetColors                        12019
  295. #define _fnum_windowSetVisible                       12020
  296. #define _fnum_windowSetMinimized                     12021 
  297. #define _fnum_windowAddConsoleTextArea               12022
  298. #define _fnum_windowRedrawArea                       12023
  299. #define _fnum_windowProcessEvent                     12024
  300. #define _fnum_windowComponentEventGet                12025
  301. #define _fnum_windowTileBackground                   12026
  302. #define _fnum_windowCenterBackground                 12027
  303. #define _fnum_windowScreenShot                       12028
  304. #define _fnum_windowSaveScreenShot                   12029
  305. #define _fnum_windowSetTextOutput                    12030
  306. #define _fnum_windowComponentSetVisible              12031
  307. #define _fnum_windowComponentSetEnabled              12032
  308. #define _fnum_windowComponentGetWidth                12033
  309. #define _fnum_windowComponentSetWidth                12034
  310. #define _fnum_windowComponentGetHeight               12035
  311. #define _fnum_windowComponentSetHeight               12036
  312. #define _fnum_windowComponentFocus                   12037
  313. #define _fnum_windowComponentDraw                    12038
  314. #define _fnum_windowComponentGetData                 12039
  315. #define _fnum_windowComponentSetData                 12040
  316. #define _fnum_windowComponentGetSelected             12041
  317. #define _fnum_windowComponentSetSelected             12042
  318. #define _fnum_windowNewButton                        12043
  319. #define _fnum_windowNewCanvas                        12044
  320. #define _fnum_windowNewCheckbox                      12045
  321. #define _fnum_windowNewContainer                     12046
  322. #define _fnum_windowNewIcon                          12047
  323. #define _fnum_windowNewImage                         12048
  324. #define _fnum_windowNewList                          12049
  325. #define _fnum_windowNewListItem                      12050
  326. #define _fnum_windowNewMenu                          12051
  327. #define _fnum_windowNewMenuBar                       12052
  328. #define _fnum_windowNewMenuItem                      12053
  329. #define _fnum_windowNewPasswordField                 12054
  330. #define _fnum_windowNewProgressBar                   12055
  331. #define _fnum_windowNewRadioButton                   12056
  332. #define _fnum_windowNewScrollBar                     12057
  333. #define _fnum_windowNewTextArea                      12058
  334. #define _fnum_windowNewTextField                     12059
  335. #define _fnum_windowNewTextLabel                     12060
  336. #define _fnum_windowDebugLayout                      12061
  337.  
  338. // User functions.  All are in the 13000-13999 range
  339. #define _fnum_userAuthenticate                       13000
  340. #define _fnum_userLogin                              13001
  341. #define _fnum_userLogout                             13002
  342. #define _fnum_userGetNames                           13003
  343. #define _fnum_userAdd                                13004
  344. #define _fnum_userDelete                             13005
  345. #define _fnum_userSetPassword                        13006
  346. #define _fnum_userGetPrivilege                       13007
  347. #define _fnum_userGetPid                             13008
  348. #define _fnum_userSetPid                             13009
  349. #define _fnum_userFileAdd                            13010
  350. #define _fnum_userFileDelete                         13011
  351. #define _fnum_userFileSetPassword                    13012
  352.  
  353. // Network functions.  All are in the 14000-14999 range
  354. #define _fnum_networkDeviceGetCount                  14000
  355. #define _fnum_networkDeviceGet                       14001
  356. #define _fnum_networkInitialized                     14002
  357. #define _fnum_networkInitialize                      14003
  358. #define _fnum_networkShutdown                        14004
  359. #define _fnum_networkOpen                            14005
  360. #define _fnum_networkClose                           14006
  361. #define _fnum_networkCount                           14007
  362. #define _fnum_networkRead                            14008
  363. #define _fnum_networkWrite                           14009
  364. #define _fnum_networkPing                            14010
  365.  
  366. // Miscellaneous functions.  All are in the 99000-99999 range
  367. #define _fnum_fontGetDefault                         99000
  368. #define _fnum_fontSetDefault                         99001
  369. #define _fnum_fontLoad                               99002
  370. #define _fnum_fontGetPrintedWidth                    99003
  371. #define _fnum_imageLoad                              99004
  372. #define _fnum_imageSave                              99005
  373. #define _fnum_shutdown                               99006
  374. #define _fnum_getVersion                             99007
  375. #define _fnum_encryptMD5                             99008
  376. #define _fnum_lockGet                                99009
  377. #define _fnum_lockRelease                            99010
  378. #define _fnum_lockVerify                             99011
  379. #define _fnum_variableListCreate                     99012
  380. #define _fnum_variableListDestroy                    99013
  381. #define _fnum_variableListGet                        99014
  382. #define _fnum_variableListSet                        99015
  383. #define _fnum_variableListUnset                      99016
  384. #define _fnum_configurationReader                    99017
  385. #define _fnum_configurationWriter                    99018
  386. #define _fnum_keyboardGetMaps                        99019
  387. #define _fnum_keyboardSetMap                         99020
  388. #define _fnum_deviceTreeGetCount                     99021
  389. #define _fnum_deviceTreeGetRoot                      99022
  390. #define _fnum_deviceTreeGetChild                     99023
  391. #define _fnum_deviceTreeGetNext                      99024
  392. #define _fnum_mouseLoadPointer                       99025
  393. #define _fnum_mouseSwitchPointer                     99026
  394.  
  395. // Utility macros for stack manipulation
  396. #define stackPush(value) \
  397.   __asm__ __volatile__ ("pushl %0 \n\t" : : "r" (value))
  398. #define stackSub(bytes)                       \
  399.   __asm__ __volatile__ ("addl %0, %%esp \n\t" \
  400.                         : : "r" (bytes) : "%esp")
  401.  
  402. // The generic calls for accessing the kernel API
  403. #define sysCall(retCode)                                    \
  404.   if (!visopsys_in_kernel)                                  \
  405.      __asm__ __volatile__ ("lcall $0x003B,$0x00000000 \n\t" \
  406.                "movl %%eax, %0 \n\t"            \
  407.                : "=r" (retCode) : : "%eax", "memory");
  408.  
  409. // These use the macros defined above to call the kernel with the
  410. // appropriate number of arguments
  411.  
  412. static inline int sysCall_0(int fnum)
  413. {
  414.   // Do a syscall with NO parameters
  415.   int status = 0;
  416.   stackPush(fnum);
  417.   stackPush(1);
  418.   sysCall(status);
  419.   stackSub(8);
  420.   return (status);
  421. }
  422.  
  423.  
  424. static inline int sysCall_1(int fnum, void *arg1)
  425. {
  426.   // Do a syscall with 1 parameter
  427.   int status = 0;
  428.   stackPush(arg1);
  429.   stackPush(fnum);
  430.   stackPush(2);
  431.   sysCall(status);
  432.   stackSub(12);
  433.   return (status);
  434. }
  435.  
  436.  
  437. static inline int sysCall_2(int fnum, void *arg1, void *arg2)
  438. {
  439.   // Do a syscall with 2 parameters
  440.   int status = 0;
  441.   stackPush(arg2);
  442.   stackPush(arg1);
  443.   stackPush(fnum);
  444.   stackPush(3);
  445.   sysCall(status);
  446.   stackSub(16);
  447.   return (status);
  448. }
  449.  
  450.  
  451. static inline int sysCall_3(int fnum, void *arg1, void *arg2, void *arg3)
  452. {
  453.   // Do a syscall with 3 parameters
  454.   int status = 0;
  455.   stackPush(arg3);
  456.   stackPush(arg2);
  457.   stackPush(arg1);
  458.   stackPush(fnum);
  459.   stackPush(4);
  460.   sysCall(status);
  461.   stackSub(20);
  462.   return (status);
  463. }
  464.  
  465.  
  466. static inline int sysCall_4(int fnum, void *arg1, void *arg2, void *arg3,
  467.                 void *arg4)
  468. {
  469.   // Do a syscall with 4 parameters
  470.   int status = 0;
  471.   stackPush(arg4);
  472.   stackPush(arg3);
  473.   stackPush(arg2);
  474.   stackPush(arg1);
  475.   stackPush(fnum);
  476.   stackPush(5);
  477.   sysCall(status);
  478.   stackSub(24);
  479.   return (status);
  480. }
  481.  
  482.  
  483. static inline int sysCall_5(int fnum, void *arg1, void *arg2, void *arg3,
  484.                 void *arg4, void *arg5)
  485. {
  486.   // Do a syscall with 5 parameters
  487.   int status = 0;
  488.   stackPush(arg5);
  489.   stackPush(arg4);
  490.   stackPush(arg3);
  491.   stackPush(arg2);
  492.   stackPush(arg1);
  493.   stackPush(fnum);
  494.   stackPush(6);
  495.   sysCall(status);
  496.   stackSub(28);
  497.   return (status);
  498. }
  499.  
  500.  
  501. static inline int sysCall_6(int fnum, void *arg1, void *arg2, void *arg3,
  502.                 void *arg4, void *arg5, void *arg6)
  503. {
  504.   // Do a syscall with 6 parameters
  505.   int status = 0;
  506.   stackPush(arg6);
  507.   stackPush(arg5);
  508.   stackPush(arg4);
  509.   stackPush(arg3);
  510.   stackPush(arg2);
  511.   stackPush(arg1);
  512.   stackPush(fnum);
  513.   stackPush(7);
  514.   sysCall(status);
  515.   stackSub(32);
  516.   return (status);
  517. }
  518.  
  519.  
  520. static inline int sysCall_7(int fnum, void *arg1, void *arg2, void *arg3,
  521.                 void *arg4, void *arg5, void *arg6, void *arg7)
  522. {
  523.   // Do a syscall with 7 parameters
  524.   int status = 0;
  525.   stackPush(arg7);
  526.   stackPush(arg6);
  527.   stackPush(arg5);
  528.   stackPush(arg4);
  529.   stackPush(arg3);
  530.   stackPush(arg2);
  531.   stackPush(arg1);
  532.   stackPush(fnum);
  533.   stackPush(8);
  534.   sysCall(status);
  535.   stackSub(36);
  536.   return (status);
  537. }
  538.  
  539.  
  540. static inline int sysCall_8(int fnum, void *arg1, void *arg2, void *arg3,
  541.                 void *arg4, void *arg5, void *arg6, void *arg7,
  542.                 void *arg8)
  543. {
  544.   // Do a syscall with 8 parameters
  545.   int status = 0;
  546.   stackPush(arg8);
  547.   stackPush(arg7);
  548.   stackPush(arg6);
  549.   stackPush(arg5);
  550.   stackPush(arg4);
  551.   stackPush(arg3);
  552.   stackPush(arg2);
  553.   stackPush(arg1);
  554.   stackPush(fnum);
  555.   stackPush(9);
  556.   sysCall(status);
  557.   stackSub(40);
  558.   return (status);
  559. }
  560.  
  561.  
  562. static inline int sysCall_9(int fnum, void *arg1, void *arg2, void *arg3,
  563.                 void *arg4, void *arg5, void *arg6, void *arg7,
  564.                 void *arg8, void *arg9)
  565. {
  566.   // Do a syscall with 9 parameters
  567.   int status = 0;
  568.   stackPush(arg9);
  569.   stackPush(arg8);
  570.   stackPush(arg7);
  571.   stackPush(arg6);
  572.   stackPush(arg5);
  573.   stackPush(arg4);
  574.   stackPush(arg3);
  575.   stackPush(arg2);
  576.   stackPush(arg1);
  577.   stackPush(fnum);
  578.   stackPush(10);
  579.   sysCall(status);
  580.   stackSub(44);
  581.   return (status);
  582. }
  583.  
  584.  
  585. // These inline functions are used to call specific kernel functions.  
  586. // There will be one of these for every API function.
  587.  
  588.  
  589. //
  590. // Text input/output functions
  591. //
  592.  
  593. _X_ static inline objectKey textGetConsoleInput(void)
  594. {
  595.   // Proto: kernelTextInputStream *kernelTextGetConsoleInput(void);
  596.   // Desc : Returns a reference to the console input stream.  This is where keyboard input goes by default.
  597.   return ((objectKey) sysCall_0(_fnum_textGetConsoleInput));
  598. }
  599.  
  600. _X_ static inline int textSetConsoleInput(objectKey newStream)
  601. {
  602.   // Proto: int kernelTextSetConsoleInput(kernelTextInputStream *);
  603.   // Desc : Changes the console input stream.  GUI programs can use this function to redirect input to a text area or text field, for example.
  604.   return (sysCall_1(_fnum_textSetConsoleInput, newStream));
  605. }
  606.  
  607. _X_ static inline objectKey textGetConsoleOutput(void)
  608. {
  609.   // Proto: kernelTextOutputStream *kernelTextGetConsoleOutput(void);
  610.   // Desc : Returns a reference to the console output stream.  This is where kernel logging output goes by default.
  611.   return ((objectKey) sysCall_0(_fnum_textGetConsoleOutput));
  612. }
  613.  
  614. _X_ static inline int textSetConsoleOutput(objectKey newStream)
  615. {
  616.   // Proto: int kernelTextSetConsoleOutput(kernelTextOutputStream *);
  617.   // Desc : Changes the console output stream.  GUI programs can use this function to redirect output to a text area or text field, for example.
  618.   return (sysCall_1(_fnum_textSetConsoleOutput, newStream));
  619. }
  620.  
  621. _X_ static inline objectKey textGetCurrentInput(void)
  622. {
  623.   // Proto: kernelTextInputStream *kernelTextGetCurrentInput(void);
  624.   // Desc : Returns a reference to the input stream of the current process.  This is where standard input (for example, from a getc() call) is received.
  625.   return ((objectKey) sysCall_0(_fnum_textGetCurrentInput));
  626. }
  627.  
  628. _X_ static inline int textSetCurrentInput(objectKey newStream)
  629. {
  630.   // Proto: int kernelTextSetCurrentInput(kernelTextInputStream *);
  631.   // Desc : Changes the current input stream.  GUI programs can use this function to redirect input to a text area or text field, for example.
  632.   return (sysCall_1(_fnum_textSetCurrentInput, newStream));
  633. }
  634.  
  635. _X_ static inline objectKey textGetCurrentOutput(void)
  636. {
  637.   // Proto: kernelTextOutputStream *kernelTextGetCurrentOutput(void);
  638.   // Desc : Returns a reference to the console output stream.
  639.   return ((objectKey) sysCall_0(_fnum_textGetCurrentOutput));
  640. }
  641.  
  642. _X_ static inline int textSetCurrentOutput(objectKey newStream)
  643. {
  644.   // Proto: int kernelTextSetCurrentOutput(kernelTextOutputStream *);
  645.   // Desc : Changes the current output stream.  This is where standard output (for example, from a putc() call) goes.
  646.   return (sysCall_1(_fnum_textSetCurrentOutput, newStream));
  647. }
  648.  
  649. _X_ static inline int textGetForeground(void)
  650. {
  651.   // Proto: int kernelTextGetForeground(void);
  652.   // Desc : Get the current foreground color as an int value.  Currently this is only applicable in text mode, and the color value should be treated as a PC built-in color value.  Here is a listing: 0=Black, 4=Red, 8=Dark gray, 12=Light red,  1=Blue, 5=Magenta, 9=Light blue, 13=Light magenta, 2=Green, 6=Brown, 10=Light green, 14=Yellow, 3=Cyan, 7=Light gray, 11=Light cyan, 15=White
  653.   return (sysCall_0(_fnum_textGetForeground));
  654. }
  655.  
  656. _X_ static inline int textSetForeground(int foreground)
  657. {
  658.   // Proto: int kernelTextSetForeground(int);
  659.   // Desc : Set the current foreground color from an int value.  Currently this is only applicable in text mode, and the color value should be treated as a PC builtin color value.  See chart above.
  660.   return (sysCall_1(_fnum_textSetForeground, (void *) foreground));
  661. }
  662.  
  663. _X_ static inline int textGetBackground(void)
  664. {
  665.   // Proto: int kernelTextGetBackground(void);
  666.   // Desc : Get the current background color as an int value.  Currently this is only applicable in text mode, and the color value should be treated as a PC builtin color value.  See chart above.
  667.   return (sysCall_0(_fnum_textGetBackground));
  668. }
  669.  
  670. _X_ static inline int textSetBackground(int background)
  671. {
  672.   // Proto: int kernelTextSetBackground(int);
  673.   // Desc : Set the current foreground color from an int value.  Currently this is only applicable in text mode, and the color value should be treated as a PC builtin color value.  See chart above.
  674.   return (sysCall_1(_fnum_textSetBackground, (void *) background));
  675. }
  676.  
  677. _X_ static inline int textPutc(int ascii)
  678. {
  679.   // Proto: int kernelTextPutc(int);
  680.   // Desc : Print a single character
  681.   return (sysCall_1(_fnum_textPutc, (void*)ascii));
  682. }
  683.  
  684. _X_ static inline int textPrint(const char *str)
  685. {
  686.   // Proto: int kernelTextPrint(const char *);
  687.   // Desc : Print a string
  688.   return (sysCall_1(_fnum_textPrint, (void *) str));
  689. }
  690.  
  691. _X_ static inline int textPrintLine(const char *str)
  692. {
  693.   // Proto: int kernelTextPrintLine(const char *);
  694.   // Desc : Print a string with a newline at the end
  695.   return (sysCall_1(_fnum_textPrintLine, (void *) str));
  696. }
  697.  
  698. _X_ static inline void textNewline(void)
  699. {
  700.   // Proto: void kernelTextNewline(void);
  701.   // Desc : Print a newline
  702.   sysCall_0(_fnum_textNewline);
  703. }
  704.  
  705. _X_ static inline int textBackSpace(void)
  706. {
  707.   // Proto: void kernelTextBackSpace(void);
  708.   // Desc : Backspace the cursor, deleting any character there
  709.   return (sysCall_0(_fnum_textBackSpace));
  710. }
  711.  
  712. _X_ static inline int textTab(void)
  713. {
  714.   // Proto: void kernelTextTab(void);
  715.   // Desc : Print a tab
  716.   return (sysCall_0(_fnum_textTab));
  717. }
  718.  
  719. _X_ static inline int textCursorUp(void)
  720. {
  721.   // Proto: void kernelTextCursorUp(void);
  722.   // Desc : Move the cursor up one row.  Doesn't affect any characters there.
  723.   return (sysCall_0(_fnum_textCursorUp));
  724. }
  725.  
  726. _X_ static inline int textCursorDown(void)
  727. {
  728.   // Proto: void kernelTextCursorDown(void);
  729.   // Desc : Move the cursor down one row.  Doesn't affect any characters there.
  730.   return (sysCall_0(_fnum_textCursorDown));
  731. }
  732.  
  733. _X_ static inline int textCursorLeft(void)
  734. {
  735.   // Proto: void kernelTextCursorLeft(void);
  736.   // Desc : Move the cursor left one column.  Doesn't affect any characters there.
  737.   return (sysCall_0(_fnum_ternelTextCursorLeft));
  738. }
  739.  
  740. _X_ static inline int textCursorRight(void)
  741. {
  742.   // Proto: void kernelTextCursorRight(void);
  743.   // Desc : Move the cursor right one column.  Doesn't affect any characters there.
  744.   return (sysCall_0(_fnum_textCursorRight));
  745. }
  746.  
  747. _X_ static inline void textScroll(int upDown)
  748. {
  749.   // Proto: void kernelTextScroll(int upDown)
  750.   // Desc : Scroll the current text area up (-1) or down (+1)
  751.   sysCall_1(_fnum_textScroll, (void *) upDown);
  752. }
  753.  
  754. _X_ static inline int textGetNumColumns(void)
  755. {
  756.   // Proto: int kernelTextGetNumColumns(void);
  757.   // Desc : Get the total number of columns in the text area.
  758.   return (sysCall_0(_fnum_textGetNumColumns));
  759. }
  760.  
  761. _X_ static inline int textGetNumRows(void)
  762. {
  763.   // Proto: int kernelTextGetNumRows(void);
  764.   // Desc : Get the total number of rows in the text area.
  765.   return (sysCall_0(_fnum_textGetNumRows));
  766. }
  767.  
  768. _X_ static inline int textGetColumn(void)
  769. {
  770.   // Proto: int kernelTextGetColumn(void);
  771.   // Desc : Get the number of the current column.  Zero-based.
  772.   return (sysCall_0(_fnum_textGetColumn));
  773. }
  774.  
  775. _X_ static inline void textSetColumn(int c)
  776. {
  777.   // Proto: void kernelTextSetColumn(int);
  778.   // Desc : Set the number of the current column.  Zero-based.  Doesn't affect any characters there.
  779.   sysCall_1(_fnum_textSetColumn, (void *) c);
  780. }
  781.  
  782. _X_ static inline int textGetRow(void)
  783. {
  784.   // Proto: int kernelTextGetRow(void);
  785.   // Desc : Get the number of the current row.  Zero-based.
  786.   return (sysCall_0(_fnum_textGetRow));
  787. }
  788.  
  789. _X_ static inline void textSetRow(int r)
  790. {
  791.   // Proto: void kernelTextSetRow(int);
  792.   // Desc : Set the number of the current row.  Zero-based.  Doesn't affect any characters there.
  793.   sysCall_1(_fnum_textSetRow, (void *) r);
  794. }
  795.  
  796. _X_ static inline void textSetCursor(int on)
  797. {
  798.   // Proto: void kernelTextSetCursor(int);
  799.   // Desc : Turn the cursor on (1) or off (0)
  800.   sysCall_1(_fnum_textSetCursor, (void *) on);
  801. }
  802.  
  803. _X_ static inline int textScreenClear(void)
  804. {
  805.   // Proto: void kernelTextScreenClear(void);
  806.   // Desc : Erase all characters in the text area and set the row and column to (0, 0)
  807.   return (sysCall_0(_fnum_textScreenClear));
  808. }
  809.  
  810. _X_ static inline int textScreenSave(void)
  811. {
  812.   // Proto: int kernelTextScreenSave(void);
  813.   // Desc : Save the current screen in an internal buffer.  Use with the textScreenRestore function.
  814.   return (sysCall_0(_fnum_textScreenSave));
  815. }
  816.  
  817. _X_ static inline int textScreenRestore(void)
  818. {
  819.   // Proto: int kernelTextScreenRestore(void);
  820.   // Desc : Restore the screen previously saved with the textScreenSave function
  821.   return (sysCall_0(_fnum_textScreenRestore));
  822. }
  823.  
  824. _X_ static inline int textInputStreamCount(objectKey strm)
  825. {
  826.   // Proto: int kernelTextInputStreamCount(kernelTextInputStream *);
  827.   // Desc : Get the number of characters currently waiting in the specified input stream
  828.   return (sysCall_1(_fnum_textInputStreamCount, strm));
  829. }
  830.  
  831. _X_ static inline int textInputCount(void)
  832. {
  833.   // Proto: int kernelTextInputCount(void);
  834.   // Desc : Get the number of characters currently waiting in the current input stream
  835.   return (sysCall_0(_fnum_textInputCount));
  836. }
  837.  
  838. _X_ static inline int textInputStreamGetc(objectKey strm, char *cp)
  839. {
  840.   // Proto: int kernelTextInputStreamGetc(kernelTextInputStream *, char *);
  841.   // Desc : Get one character from the specified input stream (as an integer value).
  842.   return (sysCall_2(_fnum_textInputStreamGetc, strm, cp));
  843. }
  844.  
  845. _X_ static inline int textInputGetc(char *cp)
  846. {
  847.   // Proto: char kernelTextInputGetc(void);
  848.   // Desc : Get one character from the default input stream (as an integer value).
  849.   return (sysCall_1(_fnum_textInputGetc, cp));
  850. }
  851.  
  852. _X_ static inline int textInputStreamReadN(objectKey strm, int num, char *buff)
  853. {
  854.   // Proto: int kernelTextInputStreamReadN(kernelTextInputStream *, int, char *);
  855.   // Desc : Read up to 'num' characters from the specified input stream into 'buff'
  856.   return (sysCall_3(_fnum_textInputStreamReadN, strm, (void *) num, buff));
  857. }
  858.  
  859. _X_ static inline int textInputReadN(int num, char *buff)
  860. {
  861.   // Proto: int kernelTextInputReadN(int, char *);
  862.   // Desc : Read up to 'num' characters from the default input stream into 'buff'
  863.   return (sysCall_2(_fnum_textInputReadN, (void *)num, buff));
  864. }
  865.  
  866. _X_ static inline int textInputStreamReadAll(objectKey strm, char *buff)
  867. {
  868.   // Proto: int kernelTextInputStreamReadAll(kernelTextInputStream *, char *);
  869.   // Desc : Read all of the characters from the specified input stream into 'buff'
  870.   return (sysCall_2(_fnum_textInputStreamReadAll, strm, buff));
  871. }
  872.  
  873. _X_ static inline int textInputReadAll(char *buff)
  874. {
  875.   // Proto: int kernelTextInputReadAll(char *);
  876.   // Desc : Read all of the characters from the default input stream into 'buff'
  877.   return (sysCall_1(_fnum_textInputReadAll, buff));
  878. }
  879.  
  880. _X_ static inline int textInputStreamAppend(objectKey strm, int ascii)
  881. {
  882.   // Proto: int kernelTextInputStreamAppend(kernelTextInputStream *, int);
  883.   // Desc : Append a character (as an integer value) to the end of the specified input stream.
  884.   return (sysCall_2(_fnum_textInputStreamAppend, strm, (void *) ascii));
  885. }
  886.  
  887. _X_ static inline int textInputAppend(int ascii)
  888. {
  889.   // Proto: int kernelTextInputAppend(int);
  890.   // Desc : Append a character (as an integer value) to the end of the default input stream.
  891.   return (sysCall_1(_fnum_textInputAppend, (void *) ascii));
  892. }
  893.  
  894. _X_ static inline int textInputStreamAppendN(objectKey strm, int num, char *str)
  895. {
  896.   // Proto: int kernelTextInputStreamAppendN(kernelTextInputStream *, int, char *);
  897.   // Desc : Append 'num' characters to the end of the specified input stream from 'str'
  898.   return (sysCall_3(_fnum_textInputStreamAppendN, strm, (void *) num, str));
  899. }
  900.  
  901. _X_ static inline int textInputAppendN(int num, char *str)
  902. {
  903.   // Proto: int kernelTextInputAppendN(int, char *);
  904.   // Desc : Append 'num' characters to the end of the default input stream from 'str'
  905.   return (sysCall_2(_fnum_textInputAppendN, (void *) num, str));
  906. }
  907.  
  908. _X_ static inline int textInputStreamRemove(objectKey strm)
  909. {
  910.   // Proto: int kernelTextInputStreamRemove(kernelTextInputStream *);
  911.   // Desc : Remove one character from the start of the specified input stream.
  912.   return (sysCall_1(_fnum_textInputStreamRemove, strm));
  913. }
  914.  
  915. _X_ static inline int textInputRemove(void)
  916. {
  917.   // Proto: int kernelTextInputRemove(void);
  918.   // Desc : Remove one character from the start of the default input stream.
  919.   return (sysCall_0(_fnum_textInputRemove));
  920. }
  921.  
  922. _X_ static inline int textInputStreamRemoveN(objectKey strm, int num)
  923. {
  924.   // Proto: int kernelTextInputStreamRemoveN(kernelTextInputStream *, int);
  925.   // Desc : Remove 'num' characters from the start of the specified input stream.
  926.   return (sysCall_2(_fnum_textInputStreamRemoveN, strm, (void *) num));
  927. }
  928.  
  929. _X_ static inline int textInputRemoveN(int num)
  930. {
  931.   // Proto: int kernelTextInputRemoveN(int);
  932.   // Desc : Remove 'num' characters from the start of the default input stream.
  933.   return (sysCall_1(_fnum_textInputRemoveN, (void *) num));
  934. }
  935.  
  936. _X_ static inline int textInputStreamRemoveAll(objectKey strm)
  937. {
  938.   // Proto: int kernelTextInputStreamRemoveAll(kernelTextInputStream *);
  939.   // Desc : Empty the specified input stream.
  940.   return (sysCall_1(_fnum_textInputStreamRemoveAll, strm));
  941. }
  942.  
  943. _X_ static inline int textInputRemoveAll(void)
  944. {
  945.   // Proto: int kernelTextInputRemoveAll(void);
  946.   // Desc : Empty the default input stream.
  947.   return (sysCall_0(_fnum_textInputRemoveAll));
  948. }
  949.  
  950. _X_ static inline void textInputStreamSetEcho(objectKey strm, int onOff)
  951. {
  952.   // Proto: void kernelTextInputStreamSetEcho(kernelTextInputStream *, int);
  953.   // Desc : Set echo on (1) or off (0) for the specified input stream.  When on, any characters typed will be automatically printed to the text area.  When off, they won't.
  954.   sysCall_2(_fnum_textInputStreamSetEcho, strm, (void *) onOff);
  955. }
  956.  
  957. _X_ static inline void textInputSetEcho(int onOff)
  958. {
  959.   // Proto: void kernelTextInputSetEcho(int);
  960.   // Desc : Set echo on (1) or off (0) for the default input stream.  When on, any characters typed will be automatically printed to the text area.  When off, they won't.
  961.   sysCall_1(_fnum_textInputSetEcho, (void *) onOff);
  962. }
  963.  
  964.  
  965. // 
  966. // Disk functions
  967. //
  968.  
  969. _X_ static inline int diskReadPartitions(char *name)
  970. {
  971.   // Proto: int kernelDiskReadPartitions(const char *);
  972.   // Desc : Tells the kernel to (re)read the partition table of disk 'name'.
  973.   return (sysCall_1(_fnum_diskReadPartitions, name));
  974. }
  975.  
  976. _X_ static inline int diskReadPartitionsAll(void)
  977. {
  978.   // Proto: int kernelDiskReadPartitionsAll(void);
  979.   // Desc : Tells the kernel to (re)read all the disks' partition tables.
  980.   return (sysCall_0(_fnum_diskReadPartitionsAll));
  981. }
  982.  
  983. _X_ static inline int diskSync(void)
  984. {
  985.   // Proto: int kernelDiskSync(void);
  986.   // Desc : Tells the kernel to synchronize all the disks, flushing any output.
  987.   return (sysCall_0(_fnum_diskSync));
  988. }
  989.  
  990. _X_ static inline int diskGetBoot(char *name)
  991. {
  992.   // Proto: int kernelDiskGetBoot(char *)
  993.   // Desc : Get the disk name of the boot device.  Normally this will contain the root filesystem.
  994.   return (sysCall_1(_fnum_diskGetBoot, name));
  995. }
  996.  
  997. _X_ static inline int diskGetCount(void)
  998. {
  999.   // Proto: int kernelDiskGetCount(void);
  1000.   // Desc : Get the number of logical disk volumes recognized by the system
  1001.   return (sysCall_0(_fnum_diskGetCount));
  1002. }
  1003.  
  1004. _X_ static inline int diskGetPhysicalCount(void)
  1005. {
  1006.   // Proto: int kernelDiskGetPhysicalCount(void);
  1007.   // Desc : Get the number of physical disk devices recognized by the system
  1008.   return (sysCall_0(_fnum_diskGetPhysicalCount));
  1009. }
  1010.  
  1011. _X_ static inline int diskGet(const char *name, disk *userDisk)
  1012. {
  1013.   // Proto: int kernelDiskGet(const char *, disk *);
  1014.   // Desc : Given a disk name string 'name', fill in the corresponding user space disk structure 'userDisk.
  1015.   return(sysCall_2(_fnum_diskGet, (void *) name, userDisk));
  1016. }
  1017.  
  1018. _X_ static inline int diskGetAll(disk *userDiskArray, unsigned buffSize)
  1019. {
  1020.   // Proto: int kernelDiskGetAll(disk *, unsigned);
  1021.   // Desc : Return user space disk structures in 'userDiskArray' for each logical disk, up to 'buffSize' bytes.
  1022.   return(sysCall_2(_fnum_diskGetAll, userDiskArray, (void *) buffSize));
  1023. }
  1024.  
  1025. _X_ static inline int diskGetAllPhysical(disk *userDiskArray, unsigned buffSize)
  1026. {
  1027.   // Proto: int kernelDiskGetAllPhysical(disk *, unsigned);
  1028.   // Desc : Return user space disk structures in 'userDiskArray' for each physical disk, up to 'buffSize' bytes.
  1029.   return(sysCall_2(_fnum_diskGetAllPhysical, userDiskArray,
  1030.            (void *) buffSize));
  1031. }
  1032.  
  1033. _X_ static inline int diskGetPartType(int code, partitionType *p)
  1034. {
  1035.   // Proto: int kernelDiskGetPartType(int, partitionType *);
  1036.   // Desc : Gets the partition type data for the corresponding code.  This function was added specifically by use by programs such as 'fdisk' to get descriptions of different types known to the kernel.
  1037.   return (sysCall_2(_fnum_diskGetPartType, (void *) code, p));
  1038. }
  1039.  
  1040. _X_ static inline partitionType *diskGetPartTypes(void)
  1041. {
  1042.   // Proto: partitionType *kernelDiskGetPartTypes(void);
  1043.   // Desc : Like diskGetPartType(), but returns a pointer to a list of all known types.  The memory is allocated dynamically and should be deallocated with a call to memoryRelease()
  1044.   return ((partitionType *) sysCall_0(_fnum_diskGetPartTypes));
  1045. }
  1046.  
  1047. _X_ static inline int diskSetLockState(const char *name, int state)
  1048. {
  1049.   // Proto: int kernelDiskSetLockState(const char *diskName, int state);
  1050.   // Desc : Set the locked state of the disk 'name' to either unlocked (0) or locked (1)
  1051.   return (sysCall_2(_fnum_diskSetLockState, (void *) name, (void *) state));
  1052. }
  1053.  
  1054. _X_ static inline int diskSetDoorState(const char *name, int state)
  1055. {
  1056.   // Proto: int kernelDiskSetDoorState(const char *, int);
  1057.   // Desc : Open (1) or close (0) the disk 'name'.  May require a unlocking the door first, see diskSetLockState().
  1058.   return (sysCall_2(_fnum_diskSetDoorState, (void *) name, (void *) state));
  1059. }
  1060.  
  1061. _X_ static inline int diskGetMediaState(const char *diskName)
  1062. {
  1063.   // Proto: int kernelDiskGetMediaState(const char *diskName)
  1064.   // Desc : Returns 1 if the removable disk 'diskName' is known to have media present.
  1065.   return (sysCall_1(_fnum_diskGetMediaState, (void *) diskName));
  1066. }
  1067.  
  1068. _X_ static inline int diskReadSectors(const char *name, unsigned sect, unsigned count, void *buf)
  1069. {
  1070.   // Proto: int kernelDiskReadSectors(const char *, unsigned, unsigned, void *)
  1071.   // Desc : Read 'count' sectors from disk 'name', starting at (zero-based) logical sector number 'sect'.  Put the data in memory area 'buf'.  This function requires supervisor privilege.
  1072.   return (sysCall_4(_fnum_diskReadSectors, (void *) name, (void *) sect,
  1073.             (void *) count, buf));
  1074. }
  1075.  
  1076. _X_ static inline int diskWriteSectors(const char *name, unsigned sect, unsigned count, const void *buf)
  1077. {
  1078.   // Proto: int kernelDiskWriteSectors(const char *, unsigned, unsigned, const void *)
  1079.   // Desc : Write 'count' sectors to disk 'name', starting at (zero-based) logical sector number 'sect'.  Get the data from memory area 'buf'.  This function requires supervisor privilege.
  1080.   return (sysCall_4(_fnum_diskWriteSectors, (void *) name, (void *) sect,
  1081.             (void *) count, (void *) buf));
  1082. }
  1083.  
  1084. _X_ static inline int diskGetFilesystemType(const char *name, char *buf, unsigned bufSize)
  1085. {
  1086.   // Proto: int kernelDiskGetFilesystemType(const char *, char *, unsigned);
  1087.   // Desc : This function attempts to explicitly detect the filesystem type on disk 'name', and copy up to 'bufSize' bytes of the filesystem type name into 'buf'.  Particularly useful for things like removable media where the correct info may not be automatically provided in the disk structure.
  1088.   return (sysCall_3(_fnum_diskGetFilesystemType, (void *) name, buf,
  1089.             (void *) bufSize));
  1090. }
  1091.  
  1092.  
  1093. //
  1094. // Filesystem functions
  1095. //
  1096.  
  1097. _X_ static inline int filesystemFormat(const char *theDisk, const char *type, const char *label, int longFormat, progress *prog)
  1098. {
  1099.   // Proto: int kernelFilesystemFormat(const char *, const char *, const char *, int, progress *);
  1100.   // Desc : Format the logical volume 'theDisk', with a string 'type' representing the preferred filesystem type (for example, "fat", "fat16", "fat32, etc).  Label it with 'label'.  'longFormat' will do a sector-by-sector format, if supported, and progress can optionally be monitored by passing a non-NULL progress structure pointer 'prog'.  It is optional for filesystem drivers to implement this function.
  1101.   return (sysCall_5(_fnum_filesystemFormat, (void *) theDisk, (void *) type,
  1102.             (void *) label, (void *) longFormat, (void *) prog));
  1103. }
  1104.  
  1105. _X_ static inline int filesystemClobber(const char *theDisk)
  1106. {
  1107.   // Proto: int kernelFilesystemClobber(const char *);
  1108.   // Desc : Clobber all known filesystem types on the logical volume 'theDisk'.  It is optional for filesystem drivers to implement this function.
  1109.   return (sysCall_1(_fnum_filesystemClobber, (void *) theDisk));
  1110. }
  1111.  
  1112. _X_ static inline int filesystemCheck(const char *name, int force, int repair, progress *prog)
  1113. {
  1114.   // Proto: int kernelFilesystemCheck(const char *, int, int, progress *)
  1115.   // Desc : Check the filesystem on disk 'name'.  If 'force' is non-zero, the filesystem will be checked regardless of whether the filesystem driver thinks it needs to be.  If 'repair' is non-zero, the filesystem driver will attempt to repair any errors found.  If 'repair' is zero, a non-zero return value may indicate that errors were found.  If 'repair' is non-zero, a non-zero return value may indicate that errors were found but could not be fixed.  Progress can optionally be monitored by passing a non-NULL progress structure pointer 'prog'.  It is optional for filesystem drivers to implement this function.
  1116.   return (sysCall_4(_fnum_filesystemCheck, (void *) name, (void *) force,
  1117.             (void *) repair, (void *) prog));
  1118. }
  1119.  
  1120. _X_ static inline int filesystemDefragment(const char *name, progress *prog)
  1121. {
  1122.   // Proto: int kernelFilesystemDefragment(const char *, progress *)
  1123.   // Desc : Defragment the filesystem on disk 'name'.  Progress can optionally be monitored by passing a non-NULL progress structure pointer 'prog'.  It is optional for filesystem drivers to implement this function.
  1124.   return (sysCall_2(_fnum_filesystemDefragment, (void *) name, (void *) prog));
  1125. }
  1126.  
  1127. _X_ static inline int filesystemResizeConstraints(const char *name, unsigned *minBlocks, unsigned *maxBlocks)
  1128. {
  1129.   // Proto: int kernelFilesystemResizeConstraints(const char *, unsigned *, unsigned *);
  1130.   // Desc : Get the minimum ('minBlocks') and maximum ('maxBlocks') number of blocks for a filesystem resize on disk 'name'.  It is optional for filesystem drivers to implement this function.
  1131.   return (sysCall_3(_fnum_filesystemResizeConstraints, (void *) name,
  1132.             (void *) minBlocks, (void *) maxBlocks));
  1133. }
  1134.  
  1135. _X_ static inline int filesystemResize(const char *name, unsigned blocks, progress *prog)
  1136. {
  1137.   // Proto: int kernelFilesystemResize(const char *, unsigned, progress *);
  1138.   // Desc : Resize the filesystem on disk 'name' to the given number of blocks 'blocks'.  Progress can optionally be monitored by passing a non-NULL progress structure pointer 'prog'.  It is optional for filesystem drivers to implement this function.
  1139.   return (sysCall_3(_fnum_filesystemResize, (void *) name, (void *) blocks,
  1140.             (void *) prog));
  1141. }
  1142.  
  1143. _X_ static inline int filesystemMount(const char *name, const char *mp)
  1144. {
  1145.   // Proto: int kernelFilesystemMount(const char *, const char *)
  1146.   // Desc : Mount the filesystem on disk 'name', using the mount point specified by the absolute pathname 'mp'.  Note that no file or directory called 'mp' should exist, as the mount function will expect to be able to create it.
  1147.   return (sysCall_2(_fnum_filesystemMount, (void *) name, (void *) mp));
  1148. }
  1149.  
  1150. _X_ static inline int filesystemUnmount(const char *mp)
  1151. {
  1152.   // Proto: int kernelFilesystemUnmount(const char *);
  1153.   // Desc : Unmount the filesystem mounted represented by the mount point 'fs'.
  1154.   return (sysCall_1(_fnum_filesystemUnmount, (void *)mp));
  1155. }
  1156.  
  1157. _X_ static inline int filesystemGetFree(const char *fs)
  1158. {
  1159.   // Proto: unsigned kernelFilesystemGetFree(const char *);
  1160.   // Desc : Returns the amount of free space on the filesystem represented by the mount point 'fs'.
  1161.   return (sysCall_1(_fnum_filesystemGetFree, (void *) fs));
  1162. }
  1163.  
  1164. _X_ static inline unsigned filesystemGetBlockSize(const char *fs)
  1165. {
  1166.   // Proto: unsigned kernelFilesystemGetBlockSize(const char *);
  1167.   // Desc : Returns the block size (for example, 512 or 1024) of the filesystem represented by the mount point 'fs'.
  1168.   return (sysCall_1(_fnum_filesystemGetBlockSize, (void *) fs));
  1169. }
  1170.  
  1171.  
  1172. //
  1173. // File functions
  1174. //
  1175.  
  1176. _X_ static inline int fileFixupPath(const char *orig, char *new)
  1177. {
  1178.   // Proto: int kernelFileFixupPath(const char *, char *);
  1179.   // Desc : Take the absolute pathname in 'orig' and fix it up.  This means eliminating extra file separator characters (for example) and resolving links or '.' or '..' components in the pathname.
  1180.   return (sysCall_2(_fnum_fileFixupPath, (void *) orig, new));
  1181. }
  1182.  
  1183. _X_ static inline int fileSeparateLast(const char *origPath, char *pathName, char *fileName)
  1184. {
  1185.   // Proto: int kernelFileSeparateLast(const char *, char *, char *);
  1186.   // Desc : This function will take a combined pathname/filename string and separate the two.  The user will pass in the "combined" string along with two pre-allocated char arrays to hold the resulting separated elements.
  1187.   return (sysCall_3(_fnum_fileSeparateLast, (char *) origPath, pathName,
  1188.             fileName));
  1189. }
  1190.  
  1191. _X_ static inline int fileGetDisk(const char *path, disk *d)
  1192. {
  1193.   // Proto: int kernelFileGetDisk(const char *, disk *);
  1194.   // Desc : Given the file name 'path', return the user space structure for the logical disk that the file resides on.
  1195.   return (sysCall_2(_fnum_fileGetDisk, (void *) path, (void *) d));
  1196. }
  1197.  
  1198. _X_ static inline int fileCount(const char *path)
  1199. {
  1200.   // Proto: int kernelFileCount(const char *);
  1201.   // Desc : Get the count of file entries from the directory referenced by 'path'.
  1202.   return (sysCall_1(_fnum_fileCount, (void *) path));
  1203. }
  1204.  
  1205. _X_ static inline int fileFirst(const char *path, file *f)
  1206. {
  1207.   // Proto: int kernelFileFirst(const char *, file *);
  1208.   // Desc : Get the first file from the directory referenced by 'path'.  Put the information in the file structure 'f'.
  1209.   return (sysCall_2(_fnum_fileFirst, (void *) path, (void *) f));
  1210. }
  1211.  
  1212. _X_ static inline int fileNext(const char *path, file *f)
  1213. {
  1214.   // Proto: int kernelFileNext(const char *, file *);
  1215.   // Desc : Get the next file from the directory referenced by 'path'.  'f' should be a file structure previously filled by a call to either fileFirst() or fileNext().
  1216.   return (sysCall_2(_fnum_fileNext, (void *) path, (void *) f));
  1217. }
  1218.  
  1219. _X_ static inline int fileFind(const char *name, file *f)
  1220. {
  1221.   // Proto: int kernelFileFind(const char *, kernelFile *);
  1222.   // Desc : Find the file referenced by 'name', and fill the file data structure 'f' with the results if successful.
  1223.   return (sysCall_2(_fnum_fileFind, (void *) name, (void *) f));
  1224. }
  1225.  
  1226. _X_ static inline int fileOpen(const char *name, int mode, file *f)
  1227. {
  1228.   // Proto: int kernelFileOpen(const char *, int, file *);
  1229.   // Desc : Open the file referenced by 'name' using the file open mode 'mode' (defined in <sys/file.h>).  Update the file data structure 'f' if successful.
  1230.   return (sysCall_3(_fnum_fileOpen, (void *) name, (void *) mode, 
  1231.             (void *) f));
  1232. }
  1233.  
  1234. _X_ static inline int fileClose(file *f)
  1235. {
  1236.   // Proto: int kernelFileClose(const char *, file *);
  1237.   // Desc : Close the previously opened file 'f'.
  1238.   return (sysCall_1(_fnum_fileClose, (void *) f));
  1239. }
  1240.  
  1241. _X_ static inline int fileRead(file *f, unsigned blocknum, unsigned blocks, unsigned char *buff)
  1242. {
  1243.   // Proto: int kernelFileRead(file *, unsigned int, unsigned int, unsigned char *);
  1244.   // Desc : Read data from the previously opened file 'f'.  'f' should have been opened in a read or read/write mode.  Read 'blocks' blocks (see the filesystem functions for information about getting the block size of a given filesystem) and put them in buffer 'buff'.
  1245.   return (sysCall_4(_fnum_fileRead, (void *) f, (void *) blocknum, 
  1246.             (void *) blocks, buff));
  1247. }
  1248.  
  1249. _X_ static inline int fileWrite(file *f, unsigned blocknum, unsigned blocks, unsigned char *buff)
  1250. {
  1251.   // Proto: int kernelFileWrite(file *, unsigned, unsigned, unsigned char *);
  1252.   // Desc : Write data to the previously opened file 'f'.  'f' should have been opened in a write or read/write mode.  Write 'blocks' blocks (see the filesystem functions for information about getting the block size of a given filesystem) from the buffer 'buff'.
  1253.   return (sysCall_4(_fnum_fileWrite, (void *) f, (void *) blocknum, 
  1254.             (void *) blocks, buff));
  1255. }
  1256.  
  1257. _X_ static inline int fileDelete(const char *name)
  1258. {
  1259.   // Proto: int kernelFileDelete(const char *);
  1260.   // Desc : Delete the file referenced by the pathname 'name'.
  1261.   return (sysCall_1(_fnum_fileDelete, (void *) name));
  1262. }
  1263.  
  1264. _X_ static inline int fileDeleteRecursive(const char *name)
  1265. {
  1266.   // Proto: int kernelFileDeleteRecursive(const char *);
  1267.   // Desc : Recursively delete filesystem items, starting with the one referenced by the pathname 'name'.
  1268.   return (sysCall_1(_fnum_fileDeleteRecursive, (void *) name));
  1269. }
  1270.  
  1271. _X_ static inline int fileDeleteSecure(const char *name)
  1272. {
  1273.   // Proto: int kernelFileDeleteSecure(const char *);
  1274.   // Desc : Securely delete the file referenced by the pathname 'name'.  If supported.
  1275.   return (sysCall_1(_fnum_fileDeleteSecure, (void *) name));
  1276. }
  1277.  
  1278. _X_ static inline int fileMakeDir(const char *name)
  1279. {
  1280.   // Proto: int kernelFileMakeDir(const char *);
  1281.   // Desc : Create a directory to be referenced by the pathname 'name'.
  1282.   return (sysCall_1(_fnum_fileMakeDir, (void *)name));
  1283. }
  1284.  
  1285. _X_ static inline int fileRemoveDir(const char *name)
  1286. {
  1287.   // Proto: int kernelFileRemoveDir(const char *);
  1288.   // Desc : Remove the directory referenced by the pathname 'name'.
  1289.   return (sysCall_1(_fnum_fileRemoveDir, (void *)name));
  1290. }
  1291.  
  1292. _X_ static inline int fileCopy(const char *src, const char *dest)
  1293. {
  1294.   // Proto: int kernelFileCopy(const char *, const char *);
  1295.   // Desc : Copy the file referenced by the pathname 'src' to the pathname 'dest'.  This will overwrite 'dest' if it already exists.
  1296.   return (sysCall_2(_fnum_fileCopy, (void *) src, (void *) dest));
  1297. }
  1298.  
  1299. _X_ static inline int fileCopyRecursive(const char *src, const char *dest)
  1300. {
  1301.   // Proto: int kernelFileCopyRecursive(const char *, const char *);
  1302.   // Desc : Recursively copy the file referenced by the pathname 'src' to the pathname 'dest'.  If 'src' is a regular file, the result will be the same as using the non-recursive call.  However if it is a directory, all contents of the directory and its subdirectories will be copied.  This will overwrite any files in the 'dest' tree if they already exist.
  1303.   return (sysCall_2(_fnum_fileCopyRecursive, (void *) src, (void *) dest));
  1304. }
  1305.  
  1306. _X_ static inline int fileMove(const char *src, const char *dest)
  1307. {
  1308.   // Proto: int kernelFileMove(const char *, const char *);
  1309.   // Desc : Move (rename) a file referenced by the pathname 'src' to the pathname 'dest'.
  1310.   return (sysCall_2(_fnum_fileMove, (void *) src, (void *) dest));
  1311. }
  1312.  
  1313. _X_ static inline int fileTimestamp(const char *name)
  1314. {
  1315.   // Proto: int kernelFileTimestamp(const char *);
  1316.   // Desc : Update the time stamp on the file referenced by the pathname 'name'
  1317.   return (sysCall_1(_fnum_fileTimestamp, (void *) name));
  1318. }
  1319.  
  1320. _X_ static inline int fileGetTemp(file *f)
  1321. {
  1322.   // Proto: int kernelFileGetTemp(void);
  1323.   // Desc : Create and open a temporary file in write mode.
  1324.   return (sysCall_1(_fnum_fileGetTemp, f));
  1325. }
  1326.  
  1327. _X_ static inline int fileStreamOpen(const char *name, int mode, fileStream *f)
  1328. {
  1329.   // Proto: int kernelFileStreamOpen(const char *, int, fileStream *);
  1330.   // Desc : Open the file referenced by the pathname 'name' for streaming operations, using the open mode 'mode' (defined in <sys/file.h>).  Fills the fileStream data structure 'f' with information needed for subsequent filestream operations.
  1331.   return (sysCall_3(_fnum_fileStreamOpen, (char *) name, (void *) mode,
  1332.             (void *) f));
  1333. }
  1334.  
  1335. _X_ static inline int fileStreamSeek(fileStream *f, int offset)
  1336. {
  1337.   // Proto: int kernelFileStreamSeek(fileStream *, int);
  1338.   // Desc : Seek the filestream 'f' to the absolute position 'offset'
  1339.   return (sysCall_2(_fnum_fileStreamSeek, (void *) f, (void *) offset));
  1340. }
  1341.  
  1342. _X_ static inline int fileStreamRead(fileStream *f, unsigned bytes, char *buff)
  1343. {
  1344.   // Proto: int kernelFileStreamRead(fileStream *, unsigned, char *);
  1345.   // Desc : Read 'bytes' bytes from the filestream 'f' and put them into 'buff'.
  1346.   return (sysCall_3(_fnum_fileStreamRead, (void *) f, (void *) bytes, buff));
  1347. }
  1348.  
  1349. _X_ static inline int fileStreamReadLine(fileStream *f, unsigned bytes, char *buff)
  1350. {
  1351.   // Proto: int kernelFileStreamReadLine(fileStream *, unsigned, char *);
  1352.   // Desc : Read a complete line of text from the filestream 'f', and put up to 'bytes' characters into 'buff'
  1353.   return (sysCall_3(_fnum_fileStreamReadLine, (void *) f, (void *) bytes,
  1354.             buff));
  1355. }
  1356.  
  1357. _X_ static inline int fileStreamWrite(fileStream *f, unsigned bytes, char *buff)
  1358. {
  1359.   // Proto: int kernelFileStreamWrite(fileStream *, unsigned, char *);
  1360.   // Desc : Write 'bytes' bytes from the buffer 'buff' to the filestream 'f'.
  1361.   return (sysCall_3(_fnum_fileStreamWrite, (void *) f, (void *) bytes, buff));
  1362. }
  1363.  
  1364. _X_ static inline int fileStreamWriteStr(fileStream *f, char *buff)
  1365. {
  1366.   // Proto: int kernelFileStreamWriteStr(fileStream *, char *);
  1367.   // Desc : Write the string in 'buff' to the filestream 'f'
  1368.   return (sysCall_2(_fnum_fileStreamWriteStr, (void *) f, buff));
  1369. }
  1370.  
  1371. _X_ static inline int fileStreamWriteLine(fileStream *f, char *buff)
  1372. {
  1373.   // Proto: int kernelFileStreamWriteLine(fileStream *, char *);
  1374.   // Desc : Write the string in 'buff' to the filestream 'f', and add a newline at the end
  1375.   return (sysCall_2(_fnum_fileStreamWriteLine, (void *) f, buff));
  1376. }
  1377.  
  1378. _X_ static inline int fileStreamFlush(fileStream *f)
  1379. {
  1380.   // Proto: int kernelFileStreamFlush(fileStream *);
  1381.   // Desc : Flush filestream 'f'.
  1382.   return (sysCall_1(_fnum_fileStreamFlush, (void *) f));
  1383. }
  1384.  
  1385. _X_ static inline int fileStreamClose(fileStream *f)
  1386. {
  1387.   // Proto: int kernelFileStreamClose(fileStream *);
  1388.   // Desc : [Flush and] close the filestream 'f'.
  1389.   return (sysCall_1(_fnum_fileStreamClose, (void *) f));
  1390. }
  1391.  
  1392.  
  1393. //
  1394. // Memory functions
  1395. //
  1396.  
  1397. _X_ static inline void *memoryGet(unsigned size, const char *desc)
  1398. {
  1399.   // Proto: void *kernelMemoryGet(unsigned, const char *);
  1400.   // Desc : Return a pointer to a new block of memory of size 'size' and (optional) physical alignment 'align', adding the (optional) description 'desc'.  If no specific alignment is required, use '0'.  Memory allocated using this function is automatically cleared (like 'calloc').
  1401.   return ((void *) sysCall_2(_fnum_memoryGet, (void *) size, (void *) desc));
  1402. }
  1403.  
  1404. _X_ static inline void *memoryGetPhysical(unsigned size, unsigned align, const char *desc)
  1405. {
  1406.   // Proto: void *kernelMemoryGetPhysical(unsigned, unsigned, const char *);
  1407.   // Desc : Return a pointer to a new physical block of memory of size 'size' and (optional) physical alignment 'align', adding the (optional) description 'desc'.  If no specific alignment is required, use '0'.  Memory allocated using this function is NOT automatically cleared.  'Physical' refers to an actual physical memory address, and is not necessarily useful to external programs.
  1408.   return ((void *) sysCall_3(_fnum_memoryGetPhysical, (void *) size,
  1409.                  (void *) align, (void *) desc));
  1410. }
  1411.  
  1412. _X_ static inline int memoryRelease(void *p)
  1413. {
  1414.   // Proto: int kernelMemoryRelease(void *);
  1415.   // Desc : Release the memory block starting at the address 'p'.  Must have been previously allocated using the memoryRequestBlock() function.
  1416.   return (sysCall_1(_fnum_memoryRelease, p));
  1417. }
  1418.  
  1419. _X_ static inline int memoryReleaseAllByProcId(int pid)
  1420. {
  1421.   // Proto: int kernelMemoryReleaseAllByProcId(int);
  1422.   // Desc : Release all memory allocated to/by the process referenced by process ID 'pid'.  Only privileged functions can release memory owned by other processes.
  1423.   return (sysCall_1(_fnum_memoryReleaseAllByProcId, (void *) pid));
  1424. }
  1425.  
  1426. _X_ static inline int memoryChangeOwner(int opid, int npid, void *addr, void **naddr)
  1427. {
  1428.   // Proto: int kernelMemoryChangeOwner(int, int, void *, void **);
  1429.   // Desc : Change the ownership of an allocated block of memory beginning at address 'addr'.  'opid' is the process ID of the currently owning process, and 'npid' is the process ID of the intended new owner.  'naddr' is filled with the new address of the memory (since it changes address spaces in the process).  Note that only a privileged process can change memory ownership.
  1430.   return (sysCall_4(_fnum_memoryChangeOwner, (void *) opid, (void *) npid, 
  1431.             addr, (void *) naddr));
  1432. }
  1433.  
  1434. _X_ static inline int memoryGetStats(memoryStats *stats, int kernel)
  1435. {
  1436.   // Proto: int kernelMemoryGetStats(memoryStats *, int);
  1437.   // Desc : Returns the current memory totals and usage values to the current output stream.  If non-zero, the flag 'kernel' will return kernel heap statistics instead of overall system statistics.
  1438.   return (sysCall_2(_fnum_memoryGetStats, stats, (void *) kernel));
  1439. }
  1440.  
  1441. _X_ static inline int memoryGetBlocks(memoryBlock *blocksArray, unsigned buffSize, int kernel)
  1442. {
  1443.   // Proto: int kernelMemoryGetBlocks(memoryBlock *, unsigned, int);
  1444.   // Desc : Returns a copy of the array of used memory blocks in 'blocksArray', up to 'buffSize' bytes.  If non-zero, the flag 'kernel' will return kernel heap blocks instead of overall heap allocations.
  1445.   return (sysCall_3(_fnum_memoryGetBlocks, blocksArray, (void *) buffSize,
  1446.             (void *) kernel));
  1447. }
  1448.  
  1449. _X_ static inline int memoryBlockInfo(void *p, memoryBlock *block)
  1450. {
  1451.   // Proto: int kernelMemoryBlockInfo(void *, memoryBlock *);
  1452.   // Desc : Fills in the structure 'block' with information about the allocated memory block starting at virtual address 'p'
  1453.   return (sysCall_2(_fnum_memoryBlockInfo, p, block));
  1454. }
  1455.  
  1456.  
  1457. //
  1458. // Multitasker functions
  1459. //
  1460.  
  1461. _X_ static inline int multitaskerCreateProcess(const char *name, int privilege, processImage *execImage)
  1462. {
  1463.   // Proto: int kernelMultitaskerCreateProcess(const char *, int, processImage *);
  1464.   // Desc : Create a new process.  'name' will be the new process' name.  'privilege' is the privilege level.  'execImage' is a processImage structure that describes the loaded location of the file, the program's desired virtual address, entry point, size, etc.  If the value returned by the call is a positive integer, the call was successful and the value is the new process' process ID.  New processes are created and left in a stopped state, so if you want it to run you will need to set it to a running state ('ready', actually) using the function call multitaskerSetProcessState().
  1465.   return (sysCall_3(_fnum_multitaskerCreateProcess, (void *) name,
  1466.             (void *) privilege, execImage));
  1467. }
  1468.  
  1469. _X_ static inline int multitaskerSpawn(void *addr, const char *name, int numargs, void *args[])
  1470. {
  1471.   // Proto: int kernelMultitaskerSpawn(void *, const char *, int, void *[]);
  1472.   // Desc : Spawn a thread from the current process.  The starting point of the code (for example, a function address) should be specified as 'addr'.  'name' will be the new thread's name.  'numargs' and 'args' will be passed as the "int argc, char *argv[]) parameters of the new thread.  If there are no arguments, these should be 0 and NULL, respectively.  If the value returned by the call is a positive integer, the call was successful and the value is the new thread's process ID.  New threads are created and made runnable, so there is no need to change its state to activate it.
  1473.   return (sysCall_4(_fnum_multitaskerSpawn, addr, (void *) name, 
  1474.             (void *) numargs, args));
  1475. }
  1476.  
  1477. _X_ static inline int multitaskerGetCurrentProcessId(void)
  1478. {
  1479.   // Proto: int kernelMultitaskerGetCurrentProcessId(void);
  1480.   // Desc : Returns the process ID of the calling program.
  1481.   return (sysCall_0(_fnum_multitaskerGetCurrentProcessId));
  1482. }
  1483.  
  1484. _X_ static inline int multitaskerGetProcess(int pid, process *proc)
  1485. {
  1486.   // Proto: int kernelMultitaskerGetProcess(int, process *);
  1487.   // Desc : Returns the process structure for the supplied process ID.
  1488.   return (sysCall_2(_fnum_multitaskerGetProcess, (void *) pid, proc));
  1489. }
  1490.  
  1491. _X_ static inline int multitaskerGetProcessByName(const char *name, process *proc)
  1492. {
  1493.   // Proto: int kernelMultitaskerGetProcessByName(const char *, process *);
  1494.   // Desc : Returns the process structure for the supplied process name
  1495.   return (sysCall_2(_fnum_multitaskerGetProcessByName, (void *) name, proc));
  1496. }
  1497.  
  1498. _X_ static inline int multitaskerGetProcesses(void *buffer, unsigned buffSize)
  1499. {
  1500.   // Proto: int kernelMultitaskerGetProcesses(void *, unsigned);
  1501.   // Desc : Fills 'buffer' with up to 'buffSize' bytes' worth of process structures, and returns the number of structures copied.
  1502.   return (sysCall_2(_fnum_multitaskerGetProcesses, buffer, (void *) buffSize));
  1503. }
  1504.  
  1505. _X_ static inline int multitaskerSetProcessState(int pid, int state)
  1506. {
  1507.   // Proto: int kernelMultitaskerSetProcessState(int, kernelProcessState);
  1508.   // Desc : Sets the state of the process referenced by process ID 'pid' to the new state 'state'.
  1509.   return (sysCall_2(_fnum_multitaskerSetProcessState, (void *) pid,
  1510.             (void *) state));
  1511. }
  1512.  
  1513. _X_ static inline int multitaskerProcessIsAlive(int pid)
  1514. {
  1515.   // Proto: int kernelMultitaskerProcessIsAlive(int);
  1516.   // Desc : Returns 1 if the process with the id 'pid' still exists and is in a 'runnable' (viable) state.  Returns 0 if the process does not exist or is in a 'finished' state.
  1517.   return (sysCall_1(_fnum_multitaskerProcessIsAlive, (void *) pid));
  1518. }
  1519.  
  1520. _X_ static inline int multitaskerSetProcessPriority(int pid, int priority)
  1521. {
  1522.   // Proto: int kernelMultitaskerSetProcessPriority(int, int);
  1523.   // Desc : Sets the priority of the process referenced by process ID 'pid' to 'priority'.
  1524.   return (sysCall_2(_fnum_multitaskerSetProcessPriority, (void *) pid, 
  1525.             (void *) priority));
  1526. }
  1527.  
  1528. _X_ static inline int multitaskerGetProcessPrivilege(int pid)
  1529. {
  1530.   // Proto: kernelMultitaskerGetProcessPrivilege(int);
  1531.   // Desc : Gets the privilege level of the process referenced by process ID 'pid'.
  1532.   return (sysCall_1(_fnum_multitaskerGetProcessPrivilege, (void *) pid));
  1533. }
  1534.  
  1535. _X_ static inline int multitaskerGetCurrentDirectory(char *buff, int buffsz)
  1536. {
  1537.   // Proto: int kernelMultitaskerGetCurrentDirectory(char *, int);
  1538.   // Desc : Returns the absolute pathname of the calling process' current directory.  Puts the value in the buffer 'buff' which is of size 'buffsz'.
  1539.   return (sysCall_2(_fnum_multitaskerGetCurrentDirectory, buff,
  1540.             (void *) buffsz));
  1541. }
  1542.  
  1543. _X_ static inline int multitaskerSetCurrentDirectory(const char *buff)
  1544. {
  1545.   // Proto: int kernelMultitaskerSetCurrentDirectory(const char *);
  1546.   // Desc : Sets the current directory of the calling process to the absolute pathname 'buff'.
  1547.   return (sysCall_1(_fnum_multitaskerSetCurrentDirectory, (void *) buff));
  1548. }
  1549.  
  1550. _X_ static inline objectKey multitaskerGetTextInput(void)
  1551. {
  1552.   // Proto: kernelTextInputStream *kernelMultitaskerGetTextInput(void);
  1553.   // Desc : Get an object key to refer to the current text input stream of the calling process.
  1554.   return((objectKey) sysCall_0(_fnum_multitaskerGetTextInput));
  1555. }
  1556.  
  1557. _X_ static inline int multitaskerSetTextInput(int processId, objectKey key)
  1558. {
  1559.   // Proto: int kernelMultitaskerSetTextInput(int, kernelTextInputStream *);
  1560.   // Desc : Set the text input stream of the process referenced by process ID 'processId' to a text stream referenced by the object key 'key'.
  1561.   return (sysCall_2(_fnum_multitaskerSetTextInput, (void *) processId, key));
  1562. }
  1563.  
  1564. _X_ static inline objectKey multitaskerGetTextOutput(void)
  1565. {
  1566.   // Proto: kernelTextOutputStream *kernelMultitaskerGetTextOutput(void);
  1567.   // Desc : Get an object key to refer to the current text output stream of the calling process.
  1568.   return((objectKey) sysCall_0(_fnum_multitaskerGetTextOutput));
  1569. }
  1570.  
  1571. _X_ static inline int multitaskerSetTextOutput(int processId, objectKey key)
  1572. {
  1573.   // Proto: int kernelMultitaskerSetTextOutput(int, kernelTextOutputStream *);
  1574.   // Desc : Set the text output stream of the process referenced by process ID 'processId' to a text stream referenced by the object key 'key'.
  1575.   return (sysCall_2(_fnum_multitaskerSetTextOutput, (void *) processId, key));
  1576. }
  1577.  
  1578. _X_ static inline int multitaskerDuplicateIO(int pid1, int pid2, int clear)
  1579. {
  1580.   // Proto: int kernelMultitaskerDuplicateIO(int, int, int);
  1581.   // Desc : Set 'pid2' to use the same input and output streams as 'pid1', and if 'clear' is non-zero, clear any pending input or output.
  1582.   return (sysCall_3(_fnum_multitaskerDuplicateIO, (void *) pid1, (void *) pid2,
  1583.             (void *) clear));
  1584. }
  1585.  
  1586. _X_ static inline int multitaskerGetProcessorTime(clock_t *clk)
  1587. {
  1588.   // Proto: int kernelMultitaskerGetProcessorTime(clock_t *);
  1589.   // Desc : Fill the clock_t structure with the amount of processor time consumed by the calling process.
  1590.   return (sysCall_1(_fnum_multitaskerGetProcessorTime, clk));
  1591. }
  1592.  
  1593. _X_ static inline void multitaskerYield(void)
  1594. {
  1595.   // Proto: void kernelMultitaskerYield(void);
  1596.   // Desc : Yield the remainder of the current processor timeslice back to the multitasker's scheduler.  It's nice to do this when you are waiting for some event, so that your process is not 'hungry' (i.e. hogging processor cycles unnecessarily).
  1597.   sysCall_0(_fnum_multitaskerYield);
  1598. }
  1599.  
  1600. _X_ static inline void multitaskerWait(unsigned ticks)
  1601. {
  1602.   // Proto: void kernelMultitaskerWait(unsigned int);
  1603.   // Desc : Yield the remainder of the current processor timeslice back to the multitasker's scheduler, and wait at least 'ticks' timer ticks before running the calling process again.  On the PC, one second is approximately 20 system timer ticks.
  1604.   sysCall_1(_fnum_multitaskerWait, (void *) ticks);
  1605. }
  1606.  
  1607. _X_ static inline int multitaskerBlock(int pid)
  1608. {
  1609.   // Proto: int kernelMultitaskerBlock(int);
  1610.   // Desc : Yield the remainder of the current processor timeslice back to the multitasker's scheduler, and block on the process referenced by process ID 'pid'.  This means that the calling process will not run again until process 'pid' has terminated.  The return value of this function is the return value of process 'pid'.
  1611.   return (sysCall_1(_fnum_multitaskerBlock, (void *) pid));
  1612. }
  1613.  
  1614. _X_ static inline int multitaskerDetach(void)
  1615. {
  1616.   // Proto: int kernelMultitaskerDetach(void);
  1617.   // Desc : This allows a program to 'daemonize', detaching from the IO streams of its parent and, if applicable, the parent stops blocking.  Useful for a process that want to operate in the background, or that doesn't want to be killed if its parent is killed.
  1618.   return (sysCall_0(_fnum_multitaskerDetach));
  1619. }
  1620.  
  1621. _X_ static inline int multitaskerKillProcess(int pid, int force)
  1622. {
  1623.   // Proto: int kernelMultitaskerKillProcess(int);
  1624.   // Desc : Terminate the process referenced by process ID 'pid'.  If 'force' is non-zero, the multitasker will attempt to ignore any errors and dismantle the process with extreme prejudice.  The 'force' flag also has the necessary side effect of killing any child threads spawned by process 'pid'.  (Otherwise, 'pid' is left in a stopped state until its threads have terminated normally).
  1625.   return (sysCall_2(_fnum_multitaskerKillProcess, (void *) pid,
  1626.             (void *) force));
  1627. }
  1628.  
  1629. _X_ static inline int multitaskerKillByName(const char *name, int force)
  1630. {
  1631.   // Proto: int kernelMultitaskerKillByName(const char *name, int force)
  1632.   // Desc : Like multitaskerKillProcess, except that it attempts to kill all instances of processes whose names match 'name'
  1633.   return (sysCall_2(_fnum_multitaskerKillByName, (void *) name,
  1634.             (void *) force));
  1635. }
  1636.  
  1637. _X_ static inline int multitaskerTerminate(int code)
  1638. {
  1639.   // Proto: int kernelMultitaskerTerminate(int);
  1640.   // Desc : Terminate the calling process, returning the exit code 'code'
  1641.   return (sysCall_1(_fnum_multitaskerTerminate, (void *) code));
  1642. }
  1643.  
  1644. _X_ static inline int multitaskerSignalSet(int processId, int sig, int on)
  1645. {
  1646.   // Proto: int kernelMultitaskerSignalSet(int, int, int);
  1647.   // Desc : Set the current process' signal handling enabled (on) or disabled for the specified signal number 'sig'
  1648.   return (sysCall_3(_fnum_multitaskerSignalSet, (void *) processId,
  1649.             (void *) sig, (void *) on));
  1650. }
  1651.  
  1652. _X_ static inline int multitaskerSignal(int processId, int sig)
  1653. {
  1654.   // Proto: int kernelMultitaskerSignal(int, int);
  1655.   // Desc : Send the requested signal 'sig' to the process 'processId'
  1656.   return (sysCall_2(_fnum_multitaskerSignal, (void *) processId,
  1657.             (void *) sig));
  1658. }
  1659.  
  1660. _X_ static inline int multitaskerSignalRead(int processId)
  1661. {
  1662.   // Proto: int kernelMultitaskerSignalRead(int);
  1663.   // Desc : Returns the number code of the next pending signal for the current process, or 0 if no signals are pending.
  1664.   return (sysCall_1(_fnum_multitaskerSignalRead, (void *) processId));
  1665. }
  1666.  
  1667. _X_ static inline int multitaskerGetIOPerm(int processId, int portNum)
  1668. {
  1669.   // Proto: int kernelMultitaskerGetIOPerm(int, int);
  1670.   // Desc : Returns 1 if the process with process ID 'processId' can do I/O on port 'portNum'
  1671.   return (sysCall_2(_fnum_multitaskerGetIOPerm, (void *) processId,
  1672.             (void *) portNum));
  1673. }
  1674.  
  1675. _X_ static inline int multitaskerSetIOPerm(int processId, int portNum, int yesNo)
  1676. {
  1677.   // Proto: int kernelMultitaskerSetIOPerm(int, int, int);
  1678.   // Desc : Set I/O permission port 'portNum' for the process with process ID 'processId'.  If 'yesNo' is non-zero, permission will be granted.
  1679.   return (sysCall_3(_fnum_multitaskerSetIOPerm, (void *) processId,
  1680.             (void *) portNum, (void *) yesNo));
  1681. }
  1682.  
  1683.  
  1684. //
  1685. // Loader functions
  1686. //
  1687.  
  1688. _X_ static inline void *loaderLoad(const char *filename, file *theFile)
  1689. {
  1690.   // Proto: void *kernelLoaderLoad(const char *, file *);
  1691.   // Desc : Load a file referenced by the pathname 'filename', and fill the file data structure 'theFile' with the details.  The pointer returned points to the resulting file data.
  1692.   return ((void *) sysCall_2(_fnum_loaderLoad, (void *) filename,
  1693.                  (void *) theFile));
  1694. }
  1695.  
  1696. _X_ static inline objectKey loaderClassify(const char *fileName, void *fileData, int size, loaderFileClass *class)
  1697. {
  1698.   // Proto: kernelFileClass *kernelLoaderClassify(const char *, void *, int, loaderFileClass *);
  1699.   // Desc : Given a file by the name 'fileName', the contents 'fileData', of size 'size', get the kernel loader's idea of the file type.  If successful, the return  value is non-NULL and the loaderFileClass structure 'class' is filled out with the known information.
  1700.   return ((objectKey) sysCall_4(_fnum_loaderClassify, (char *) fileName,
  1701.                 fileData, (void *) size, class));
  1702. }
  1703.  
  1704. _X_ static inline objectKey loaderClassifyFile(const char *fileName, loaderFileClass *class)
  1705. {
  1706.   // Proto: kernelFileClass *kernelLoaderClassifyFile(const char *, loaderFileClass *);
  1707.   // Desc : Like loaderClassify(), except the first argument 'fileName' is a file name to classify.  Returns the kernel loader's idea of the file type.  If successful, the return value is non-NULL and the loaderFileClass structure 'class' is filled out with the known information.
  1708.   return ((objectKey) sysCall_2(_fnum_loaderClassifyFile, (void *) fileName,
  1709.                 class));
  1710. }
  1711.  
  1712. _X_ static inline loaderSymbolTable *loaderGetSymbols(const char *fileName, int dynamic)
  1713. {
  1714.   // Proto: loaderSymbolTable *kernelLoaderGetSymbols(const char *, int);
  1715.   // Desc : Given a binary executable, library, or object file 'fileName' and a flag 'dynamic', return a loaderSymbolTable structure filled out with the loader symbols from the file.  If 'dynamic' is non-zero, only symbols used in dynamic linking will be returned (if the file is not a dynamic library or executable, NULL will be returned).  If 'dynamic' is zero, return all symbols found in the file.
  1716.   return ((loaderSymbolTable *) sysCall_2(_fnum_loaderGetSymbols,
  1717.                   (void *) fileName, (void *) dynamic));
  1718. }
  1719.  
  1720. _X_ static inline int loaderLoadProgram(const char *command, int privilege)
  1721. {
  1722.   // Proto: int kernelLoaderLoadProgram(const char *, int);
  1723.   // Desc : Run 'command' as a process with the privilege level 'privilege'.  If successful, the call's return value is the process ID of the new process.  The process is left in a stopped state and must be set to a running state explicitly using the multitasker function multitaskerSetProcessState() or the loader function loaderExecProgram().
  1724.   return (sysCall_2(_fnum_loaderLoadProgram, (void *) command,
  1725.             (void *) privilege));
  1726. }
  1727.  
  1728. _X_ static inline int loaderLoadLibrary(const char *libraryName)
  1729. {
  1730.   // Proto: int kernelLoaderLoadLibrary(const char *);
  1731.   // Desc : This takes the name of a library file 'libraryName' to load and creates a shared library in the kernel.  This function is not especially useful to user programs, since normal shared library loading happens automatically as part of the 'loaderLoadProgram' process.
  1732.   return (sysCall_1(_fnum_loaderLoadLibrary, (void *) libraryName));
  1733. }
  1734.  
  1735. _X_ static inline int loaderExecProgram(int processId, int block)
  1736. {
  1737.   // Proto: int kernelLoaderExecProgram(int, int);
  1738.   // Desc : Execute the process referenced by process ID 'processId'.  If 'block' is non-zero, the calling process will block until process 'pid' has terminated, and the return value of the call is the return value of process 'pid'.
  1739.   return (sysCall_2(_fnum_loaderExecProgram, (void *) processId,
  1740.             (void *) block));
  1741. }
  1742.  
  1743. _X_ static inline int loaderLoadAndExec(const char *command, int privilege, int block)
  1744. {
  1745.   // Proto: int kernelLoaderLoadAndExec(const char *, int, int);
  1746.   // Desc : This function is just for convenience, and is an amalgamation of the loader functions loaderLoadProgram() and  loaderExecProgram().
  1747.   return (sysCall_3(_fnum_loaderLoadAndExec, (void *) command,
  1748.             (void *) privilege, (void *) block));
  1749. }
  1750.  
  1751.  
  1752. //
  1753. // Real-time clock functions
  1754. //
  1755.  
  1756. _X_ static inline int rtcReadSeconds(void)
  1757. {
  1758.   // Proto: int kernelRtcReadSeconds(void);
  1759.   // Desc : Get the current seconds value.
  1760.   return (sysCall_0(_fnum_rtcReadSeconds));
  1761. }
  1762.  
  1763. _X_ static inline int rtcReadMinutes(void)
  1764. {
  1765.   // Proto: int kernelRtcReadMinutes(void);
  1766.   // Desc : Get the current minutes value.
  1767.   return (sysCall_0(_fnum_rtcReadMinutes));
  1768. }
  1769.  
  1770. _X_ static inline int rtcReadHours(void)
  1771. {
  1772.   // Proto: int kernelRtcReadHours(void);
  1773.   // Desc : Get the current hours value.
  1774.   return (sysCall_0(_fnum_rtcReadHours));
  1775. }
  1776.  
  1777. _X_ static inline int rtcDayOfWeek(unsigned day, unsigned month, unsigned year)
  1778. {
  1779.   // Proto: int kernelRtcDayOfWeek(unsigned, unsigned, unsigned);
  1780.   // Desc : Get the current day of the week value.
  1781.   return (sysCall_3(_fnum_rtcDayOfWeek, (void *) day, (void *) month,
  1782.             (void *) year));
  1783. }
  1784.  
  1785. _X_ static inline int rtcReadDayOfMonth(void)
  1786. {
  1787.   // Proto: int kernelRtcReadDayOfMonth(void);
  1788.   // Desc : Get the current day of the month value.
  1789.   return (sysCall_0(_fnum_rtcReadDayOfMonth));
  1790. }
  1791.  
  1792. _X_ static inline int rtcReadMonth(void)
  1793. {
  1794.   // Proto: int kernelRtcReadMonth(void);
  1795.   // Desc : Get the current month value.
  1796.   return (sysCall_0(_fnum_rtcReadMonth));
  1797. }
  1798.  
  1799. _X_ static inline int rtcReadYear(void)
  1800. {
  1801.   // Proto: int kernelRtcReadYear(void);
  1802.   // Desc : Get the current year value.
  1803.   return (sysCall_0(_fnum_rtcReadYear));
  1804. }
  1805.  
  1806. _X_ static inline unsigned rtcUptimeSeconds(void)
  1807. {
  1808.   // Proto: unsigned kernelRtcUptimeSeconds(void);
  1809.   // Desc : Get the number of seconds the system has been running.
  1810.   return (sysCall_0(_fnum_rtcUptimeSeconds));
  1811. }
  1812.  
  1813.  
  1814. _X_ static inline int rtcDateTime(struct tm *theTime)
  1815. {
  1816.   // Proto: int kernelRtcDateTime(struct tm *);
  1817.   // Desc : Get the current data and time as a tm data structure in 'theTime'.
  1818.   return (sysCall_1(_fnum_rtcDateTime, (void *) theTime));
  1819. }
  1820.  
  1821.  
  1822. //
  1823. // Random number functions
  1824. //
  1825.  
  1826. _X_ static inline unsigned randomUnformatted(void)
  1827. {
  1828.   // Proto: unsigned kernelRandomUnformatted(void);
  1829.   // Desc : Get an unformatted random unsigned number.  Just any unsigned number.
  1830.   return (sysCall_0(_fnum_randomUnformatted));
  1831. }
  1832.  
  1833. _X_ static inline unsigned randomFormatted(unsigned start, unsigned end)
  1834. {
  1835.   // Proto: unsigned kernelRandomFormatted(unsigned int, unsigned int);
  1836.   // Desc : Get a random unsigned number between the start value 'start' and the end value 'end', inclusive.
  1837.   return (sysCall_2(_fnum_randomFormatted, (void *) start, (void *) end));
  1838. }
  1839.  
  1840. _X_ static inline unsigned randomSeededUnformatted(unsigned seed)
  1841. {
  1842.   // Proto: unsigned kernelRandomSeededUnformatted(unsigned int);
  1843.   // Desc : Get an unformatted random unsigned number, using the random seed 'seed' instead of the kernel's default random seed.
  1844.   return (sysCall_1(_fnum_randomSeededUnformatted, (void *) seed));
  1845. }
  1846.  
  1847. _X_ static inline unsigned randomSeededFormatted(unsigned seed, unsigned start, unsigned end)
  1848. {
  1849.   // Proto: unsigned kernelRandomSeededFormatted(unsigned int, unsigned int, unsigned int);
  1850.   // Desc : Get a random unsigned number between the start value 'start' and the end value 'end', inclusive, using the random seed 'seed' instead of the kernel's default random seed.
  1851.   return (sysCall_3(_fnum_randomSeededFormatted, (void *) seed,
  1852.             (void *) start, (void *) end));
  1853. }
  1854.  
  1855.  
  1856. //
  1857. // Environment functions
  1858. //
  1859.  
  1860. _X_ static inline int environmentGet(const char *var, char *buf, unsigned bufsz)
  1861. {
  1862.   // Proto: int kernelEnvironmentGet(const char *, char *, unsigned int);
  1863.   // Desc : Get the value of the environment variable named 'var', and put it into the buffer 'buf' of size 'bufsz' if successful.
  1864.   return (sysCall_3(_fnum_environmentGet, (void *) var, buf, (void *) bufsz));
  1865. }
  1866.  
  1867. _X_ static inline int environmentSet(const char *var, const char *val)
  1868. {
  1869.   // Proto: int kernelEnvironmentSet(const char *, const char *);
  1870.   // Desc : Set the environment variable 'var' to the value 'val', overwriting any old value that might have been previously set.
  1871.   return (sysCall_2(_fnum_environmentSet, (void *) var, (void *) val));
  1872. }
  1873.  
  1874. _X_ static inline int environmentUnset(const char *var)
  1875. {
  1876.   // Proto: int kernelEnvironmentUnset(const char *);
  1877.   // Desc : Delete the environment variable 'var'.
  1878.   return (sysCall_1(_fnum_environmentUnset, (void *) var));
  1879. }
  1880.  
  1881. _X_ static inline void environmentDump(void)
  1882. {
  1883.   // Proto: void kernelEnvironmentDump(void);
  1884.   // Desc : Print a listing of all the currently set environment variables in the calling process' environment space to the current text output stream.
  1885.   sysCall_0(_fnum_environmentDump);
  1886. }
  1887.  
  1888.  
  1889. //
  1890. // Raw graphics functions
  1891. //
  1892.  
  1893. _X_ static inline int graphicsAreEnabled(void)
  1894. {
  1895.   // Proto: int kernelGraphicsAreEnabled(void);
  1896.   // Desc : Returns 1 if the kernel is operating in graphics mode.
  1897.   return (sysCall_0(_fnum_graphicsAreEnabled));
  1898. }
  1899.  
  1900. _X_ static inline int graphicGetModes(videoMode *buffer, unsigned size)
  1901. {
  1902.   // Proto: int kernelGraphicGetModes(videoMode *, unsigned);
  1903.   // Desc : Get up to 'size' bytes worth of videoMode structures in 'buffer' for the supported video modes of the current hardware.
  1904.   return (sysCall_2(_fnum_graphicGetModes, buffer, (void *) size));
  1905. }
  1906.  
  1907. _X_ static inline int graphicGetMode(videoMode *mode)
  1908. {
  1909.   // Proto: int kernelGraphicGetMode(videoMode *);
  1910.   // Desc : Get the current video mode in 'mode'
  1911.   return (sysCall_1(_fnum_graphicGetMode, mode));
  1912. }
  1913.  
  1914. _X_ static inline int graphicSetMode(videoMode *mode)
  1915. {
  1916.   // Proto: int kernelGraphicSetMode(videoMode *);
  1917.   // Desc : Set the video mode in 'mode'.  Generally this will require a reboot in order to take effect.
  1918.   return (sysCall_1(_fnum_graphicSetMode, mode));
  1919. }
  1920.  
  1921. _X_ static inline int graphicGetScreenWidth(void)
  1922. {
  1923.   // Proto: int kernelGraphicGetScreenWidth(void);
  1924.   // Desc : Returns the width of the graphics screen.
  1925.   return (sysCall_0(_fnum_graphicGetScreenWidth));
  1926. }
  1927.  
  1928. _X_ static inline int graphicGetScreenHeight(void)
  1929. {
  1930.   // Proto: int kernelGraphicGetScreenHeight(void);
  1931.   // Desc : Returns the height of the graphics screen.
  1932.   return (sysCall_0(_fnum_graphicGetScreenHeight));
  1933. }
  1934.  
  1935. _X_ static inline int graphicCalculateAreaBytes(int width, int height)
  1936. {
  1937.   // Proto: int kernelGraphicCalculateAreaBytes(int, int);
  1938.   // Desc : Returns the number of bytes required to allocate a graphic buffer of width 'width' and height 'height'.  This is a function of the screen resolution, etc.
  1939.   return (sysCall_2(_fnum_graphicCalculateAreaBytes, (void *) width,
  1940.             (void *) height));
  1941. }
  1942.  
  1943. _X_ static inline int graphicClearScreen(color *background)
  1944. {
  1945.   // Proto: int kernelGraphicClearScreen(color *);
  1946.   // Desc : Clear the screen to the background color 'background'.
  1947.   return (sysCall_1(_fnum_graphicClearScreen, background));
  1948. }
  1949.  
  1950. _X_ static inline int graphicGetColor(const char *colorName, color *getColor)
  1951. {
  1952.   // Proto: int kernelGraphicGetColor(const char *, color *);
  1953.   // Desc : Get the system color 'colorName' and place its values in the color structure 'getColor'.  Examples of system color names include 'foreground', 'background', and 'desktop'.
  1954.   return (sysCall_2(_fnum_graphicGetColor, (void *) colorName, getColor));
  1955. }
  1956.  
  1957. _X_ static inline int graphicSetColor(const char *colorName, color *setColor)
  1958. {
  1959.   // Proto: int kernelGraphicSetColor(const char *, color *);
  1960.   // Desc : Set the system color 'colorName' to the values in the color structure 'getColor'.  Examples of system color names include 'foreground', 'background', and 'desktop'.
  1961.   return (sysCall_2(_fnum_graphicSetColor, (void *) colorName, setColor));
  1962. }
  1963.  
  1964. _X_ static inline int graphicDrawPixel(objectKey buffer, color *foreground, drawMode mode, int xCoord, int yCoord)
  1965. {
  1966.   // Proto: int kernelGraphicDrawPixel(kernelGraphicBuffer *, color *, drawMode, int, int);
  1967.   // Desc : Draw a single pixel into the graphic buffer 'buffer', using the color 'foreground', the drawing mode 'drawMode' (for example, 'draw_normal' or 'draw_xor'), the X coordinate 'xCoord' and the Y coordinate 'yCoord'.  If 'buffer' is NULL, draw directly onto the screen.
  1968.   return (sysCall_5(_fnum_graphicDrawPixel, buffer, foreground, (void *) mode,
  1969.             (void *) xCoord, (void *) yCoord));
  1970. }
  1971.  
  1972. _X_ static inline int graphicDrawLine(objectKey buffer, color *foreground, drawMode mode, int startX, int startY, int endX, int endY)
  1973. {
  1974.   // Proto: int kernelGraphicDrawLine(kernelGraphicBuffer *, color *, drawMode, int, int, int, int);
  1975.   // Desc : Draw a line into the graphic buffer 'buffer', using the color 'foreground', the drawing mode 'drawMode' (for example, 'draw_normal' or 'draw_xor'), the starting X coordinate 'startX', the starting Y coordinate 'startY', the ending X coordinate 'endX' and the ending Y coordinate 'endY'.  At the time of writing, only horizontal and vertical lines are supported by the linear framebuffer graphic driver.  If 'buffer' is NULL, draw directly onto the screen.
  1976.   return (sysCall_7(_fnum_graphicDrawLine, buffer, foreground, (void *) mode,
  1977.             (void *) startX, (void *) startY, (void *) endX,
  1978.             (void *) endY));
  1979. }
  1980.  
  1981. _X_ static inline int graphicDrawRect(objectKey buffer, color *foreground, drawMode mode, int xCoord, int yCoord, int width, int height, int thickness, int fill)
  1982. {
  1983.   // Proto: int kernelGraphicDrawRect(kernelGraphicBuffer *, color *, drawMode, int, int, int, int, int, int);
  1984.   // Desc : Draw a rectangle into the graphic buffer 'buffer', using the color 'foreground', the drawing mode 'drawMode' (for example, 'draw_normal' or 'draw_xor'), the starting X coordinate 'xCoord', the starting Y coordinate 'yCoord', the width 'width', the height 'height', the line thickness 'thickness' and the fill value 'fill'.  Non-zero fill value means fill the rectangle.   If 'buffer' is NULL, draw directly onto the screen.
  1985.   return (sysCall_9(_fnum_graphicDrawRect, buffer, foreground, (void *) mode,
  1986.             (void *) xCoord, (void *) yCoord, (void *) width,
  1987.             (void *) height, (void *) thickness, (void *) fill));
  1988. }
  1989.  
  1990. _X_ static inline int graphicDrawOval(objectKey buffer, color *foreground, drawMode mode, int xCoord, int yCoord, int width, int height, int thickness, int fill)
  1991. {
  1992.   // Proto: int kernelGraphicDrawOval(kernelGraphicBuffer *, color *, drawMode, int, int, int, int, int, int);
  1993.   // Desc : Draw an oval (circle, whatever) into the graphic buffer 'buffer', using the color 'foreground', the drawing mode 'drawMode' (for example, 'draw_normal' or 'draw_xor'), the starting X coordinate 'xCoord', the starting Y coordinate 'yCoord', the width 'width', the height 'height', the line thickness 'thickness' and the fill value 'fill'.  Non-zero fill value means fill the oval.   If 'buffer' is NULL, draw directly onto the screen.  Currently not supported by the linear framebuffer graphic driver.
  1994.   return (sysCall_9(_fnum_graphicDrawOval, buffer, foreground, (void *) mode,
  1995.             (void *) xCoord, (void *) yCoord, (void *) width,
  1996.             (void *) height, (void *) thickness, (void *) fill));
  1997. }
  1998.  
  1999. _X_ static inline int graphicDrawImage(objectKey buffer, image *drawImage, drawMode mode, int xCoord, int yCoord, int xOffset, int yOffset, int width, int height)
  2000. {
  2001.   // Proto: int kernelGraphicDrawImage(kernelGraphicBuffer *, image *, drawMode, int, int, int, int, int, int);
  2002.   // Desc : Draw the image 'drawImage' into the graphic buffer 'buffer', using the drawing mode 'mode' (for example, 'draw_normal' or 'draw_xor'), the starting X coordinate 'xCoord' and the starting Y coordinate 'yCoord'.   The 'xOffset' and 'yOffset' parameters specify an offset into the image to start the drawing (0, 0 to draw the whole image).  Similarly the 'width' and 'height' parameters allow you to specify a portion of the image (0, 0 to draw the whole image -- minus any X or Y offsets from the previous parameters).  So, for example, to draw only the middle pixel of a 3x3 image, you would specify xOffset=1, yOffset=1, width=1, height=1.  If 'buffer' is NULL, draw directly onto the screen.
  2003.   return (sysCall_9(_fnum_graphicDrawImage, buffer, drawImage, (void *) mode,
  2004.             (void *) xCoord, (void *) yCoord, (void *) xOffset,
  2005.             (void *) yOffset, (void *) width, (void *) height));
  2006. }
  2007.  
  2008. _X_ static inline int graphicGetImage(objectKey buffer, image *getImage, int xCoord, int yCoord, int width, int height)
  2009. {
  2010.   // Proto: int kernelGraphicGetImage(kernelGraphicBuffer *, image *, int, int, int, int);
  2011.   // Desc : Grab a new image 'getImage' from the graphic buffer 'buffer', using the starting X coordinate 'xCoord', the starting Y coordinate 'yCoord', the width 'width' and the height 'height'.   If 'buffer' is NULL, grab the image directly from the screen.
  2012.   return (sysCall_6(_fnum_graphicGetImage, buffer, getImage, (void *) xCoord,
  2013.             (void *) yCoord, (void *) width, (void *) height));
  2014. }
  2015.  
  2016. _X_ static inline int graphicDrawText(objectKey buffer, color *foreground, color *background, objectKey font, const char *text, drawMode mode, int xCoord, int yCoord)
  2017. {
  2018.   // Proto: int kernelGraphicDrawText(kernelGraphicBuffer *, color *, color *, kernelAsciiFont *, const char *, drawMode, int, int);
  2019.   // Desc : Draw the text string 'text' into the graphic buffer 'buffer', using the colors 'foreground' and 'background', the font 'font', the drawing mode 'drawMode' (for example, 'draw_normal' or 'draw_xor'), the starting X coordinate 'xCoord', the starting Y coordinate 'yCoord'.   If 'buffer' is NULL, draw directly onto the screen.  If 'font' is NULL, use the default font.
  2020.   return (sysCall_8(_fnum_graphicDrawText, buffer, foreground, background,
  2021.             font, (void *) text, (void *) mode, (void *) xCoord,
  2022.             (void *) yCoord));
  2023. }
  2024.  
  2025. _X_ static inline int graphicCopyArea(objectKey buffer, int xCoord1, int yCoord1, int width, int height, int xCoord2, int yCoord2)
  2026. {
  2027.   // Proto: int kernelGraphicCopyArea(kernelGraphicBuffer *, int, int, int, int, int, int);
  2028.   // Desc : Within the graphic buffer 'buffer', copy the area bounded by ('xCoord1', 'yCoord1'), width 'width' and height 'height' to the starting X coordinate 'xCoord2' and the starting Y coordinate 'yCoord2'.  If 'buffer' is NULL, copy directly to and from the screen.
  2029.   return (sysCall_7(_fnum_graphicCopyArea, buffer, (void *) xCoord1,
  2030.             (void *) yCoord1, (void *) width, (void *) height,
  2031.             (void *) xCoord2, (void *) yCoord2));
  2032. }
  2033.  
  2034. _X_ static inline int graphicClearArea(objectKey buffer, color *background, int xCoord, int yCoord, int width, int height)
  2035. {
  2036.   // Proto: int kernelGraphicClearArea(kernelGraphicBuffer *, color *, int, int, int, int);
  2037.   // Desc : Clear the area of the graphic buffer 'buffer' using the background color 'background', using the starting X coordinate 'xCoord', the starting Y coordinate 'yCoord', the width 'width' and the height 'height'.  If 'buffer' is NULL, clear the area directly on the screen.
  2038.   return (sysCall_6(_fnum_graphicClearArea, buffer, background,
  2039.             (void *) xCoord, (void *) yCoord, (void *) width,
  2040.             (void *) height));
  2041. }
  2042.  
  2043. _X_ static inline int graphicRenderBuffer(objectKey buffer, int drawX, int drawY, int clipX, int clipY, int clipWidth, int clipHeight)
  2044. {
  2045.   // Proto: int kernelGraphicRenderBuffer(kernelGraphicBuffer *, int, int, int, int, int, int); 
  2046.   // Desc : Draw the clip of the buffer 'buffer' onto the screen.  Draw it on the screen at starting X coordinate 'drawX' and starting Y coordinate 'drawY'.  The buffer clip is bounded by the starting X coordinate 'clipX', the starting Y coordinate 'clipY', the width 'clipWidth' and the height 'clipHeight'.  It is not legal for 'buffer' to be NULL in this case.
  2047.   return (sysCall_7(_fnum_graphicRenderBuffer, buffer, (void *) drawX,
  2048.             (void *) drawY, (void *) clipX, (void *) clipY,
  2049.             (void *) clipWidth, (void *) clipHeight));
  2050. }
  2051.  
  2052.  
  2053. //
  2054. // Windowing system functions
  2055. //
  2056.  
  2057. _X_ static inline int windowLogin(const char *userName)
  2058. {
  2059.   // Proto: kernelWindowLogin(const char *, const char *);
  2060.   // Desc : Log the user into the window environment with 'userName'.  The return value is the PID of the window shell for this session.  The calling program must have supervisor privilege in order to use this function.
  2061.   return (sysCall_1(_fnum_windowLogin, (void *) userName));
  2062. }
  2063.  
  2064. _X_ static inline int windowLogout(void)
  2065. {
  2066.   // Proto: kernelWindowLogout(void);
  2067.   // Desc : Log the current user out of the windowing system.  This kills the window shell process returned by windowLogin() call.
  2068.   return (sysCall_0(_fnum_windowLogout));
  2069. }
  2070.  
  2071. _X_ static inline objectKey windowNew(int processId, const char *title)
  2072. {
  2073.   // Proto: kernelWindow *kernelWindowNew(int, const char *);
  2074.   // Desc : Create a new window, owned by the process 'processId', and with the title 'title'.  Returns an object key to reference the window, needed by most other window functions below (such as adding components to the window)
  2075.   return ((objectKey) sysCall_2(_fnum_windowNew, (void *) processId,
  2076.                 (void *) title));
  2077. }
  2078.  
  2079. _X_ static inline objectKey windowNewDialog(objectKey parent, const char *title)
  2080. {
  2081.   // Proto: kernelWindow *kernelWindowNewDialog(kernelWindow *, const char *);
  2082.   // Desc : Create a dialog window to associate with the parent window 'parent', using the supplied title.  In the current implementation, dialog windows are modal, which is the main characteristic distinguishing them from regular windows.
  2083.   return ((objectKey) sysCall_2(_fnum_windowNewDialog, parent,
  2084.                 (void *) title));
  2085. }
  2086.  
  2087. _X_ static inline int windowDestroy(objectKey window)
  2088. {
  2089.   // Proto: int kernelWindowDestroy(kernelWindow *);
  2090.   // Desc : Destroy the window referenced by the object key 'wndow'
  2091.   return (sysCall_1(_fnum_windowDestroy, window));
  2092. }
  2093.  
  2094. _X_ static inline int windowUpdateBuffer(void *buffer, int xCoord, int yCoord, int width, int height)
  2095. {
  2096.   // Proto: kernelWindowUpdateBuffer(kernelGraphicBuffer *, int, int, int, int);
  2097.   // Desc : Tells the windowing system to redraw the visible portions of the graphic buffer 'buffer', using the given clip coordinates/size.
  2098.   return (sysCall_5(_fnum_windowUpdateBuffer, buffer, (void *) xCoord,
  2099.             (void *) yCoord, (void *) width, (void *) height));
  2100. }
  2101.  
  2102. _X_ static inline int windowSetTitle(objectKey window, const char *title)
  2103. {
  2104.   // Proto: int kernelWindowSetTitle(kernelWindow *, const char *);
  2105.   // Desc : Set the new title of window 'window' to be 'title'.
  2106.   return (sysCall_2(_fnum_windowSetTitle, window, (void *) title));
  2107. }
  2108.  
  2109.  
  2110. _X_ static inline int windowGetSize(objectKey window, int *width, int *height)
  2111. {
  2112.   // Proto: int kernelWindowGetSize(kernelWindow *, int *, int *);
  2113.   // Desc : Get the size of the window 'window', and put the results in 'width' and 'height'.
  2114.   return (sysCall_3(_fnum_windowGetSize, window, width, height));
  2115. }
  2116.  
  2117. _X_ static inline int windowSetSize(objectKey window, int width, int height)
  2118. {
  2119.   // Proto: int kernelWindowSetSize(kernelWindow *, int, int);
  2120.   // Desc : Resize the window 'window' to the width 'width' and the height 'height'.
  2121.   return (sysCall_3(_fnum_windowSetSize, window, (void *) width,
  2122.             (void *) height));
  2123. }
  2124.  
  2125. _X_ static inline int windowGetLocation(objectKey window, int *xCoord, int *yCoord)
  2126. {
  2127.   // Proto: int kernelWindowGetLocation(kernelWindow *, int *, int *);
  2128.   // Desc : Get the current screen location of the window 'window' and put it into the coordinate variables 'xCoord' and 'yCoord'.
  2129.   return (sysCall_3(_fnum_windowGetLocation, window, xCoord, yCoord));
  2130. }
  2131.  
  2132. _X_ static inline int windowSetLocation(objectKey window, int xCoord, int yCoord)
  2133. {
  2134.   // Proto: int kernelWindowSetLocation(kernelWindow *, int, int);
  2135.   // Desc : Set the screen location of the window 'window' using the coordinate variables 'xCoord' and 'yCoord'.
  2136.   return (sysCall_3(_fnum_windowSetLocation, window, (void *) xCoord,
  2137.             (void *) yCoord));
  2138. }
  2139.  
  2140. _X_ static inline int windowCenter(objectKey window)
  2141. {
  2142.   // Proto: int kernelWindowCenter(kernelWindow *);
  2143.   // Desc : Center 'window' on the screen.
  2144.   return (sysCall_1(_fnum_windowCenter, window));
  2145. }
  2146.  
  2147. _X_ static inline int windowSnapIcons(objectKey parent)
  2148. {
  2149.   // Proto: void kernelWindowSnapIcons(void *);
  2150.   // Desc : If 'parent' (either a window or a windowContainer) has icon components inside it, this will snap them to a grid.
  2151.   return (sysCall_1(_fnum_windowSnapIcons, parent));
  2152. }
  2153.  
  2154. _X_ static inline int windowSetHasBorder(objectKey window, int trueFalse)
  2155. {
  2156.   // Proto: int kernelWindowSetHasBorder(kernelWindow *, int);
  2157.   // Desc : Tells the windowing system whether to draw a border around the window 'window'.  'trueFalse' being non-zero means draw a border.  Windows have borders by default.
  2158.   return (sysCall_2(_fnum_windowSetHasBorder, window, (void *) trueFalse));
  2159. }
  2160.  
  2161. _X_ static inline int windowSetHasTitleBar(objectKey window, int trueFalse)
  2162. {
  2163.   // Proto: int kernelWindowSetHasTitleBar(kernelWindow *, int);
  2164.   // Desc : Tells the windowing system whether to draw a title bar on the window 'window'.  'trueFalse' being non-zero means draw a title bar.  Windows have title bars by default.
  2165.   return (sysCall_2(_fnum_windowSetHasTitleBar, window, (void *) trueFalse));
  2166. }
  2167.  
  2168. _X_ static inline int windowSetMovable(objectKey window, int trueFalse)
  2169. {
  2170.   // Proto: int kernelWindowSetMovable(kernelWindow *, int);
  2171.   // Desc : Tells the windowing system whether the window 'window' should be movable by the user (i.e. clicking and dragging it).  'trueFalse' being non-zero means the window is movable.  Windows are movable by default.
  2172.   return (sysCall_2(_fnum_windowSetMovable, window, (void *) trueFalse));
  2173. }
  2174.  
  2175. _X_ static inline int windowSetResizable(objectKey window, int trueFalse)
  2176. {
  2177.   // Proto: int kernelWindowSetResizable(kernelWindow *, int);
  2178.   // Desc : Tells the windowing system whether to allow 'window' to be resized by the user.  'trueFalse' being non-zero means the window is resizable.  Windows are resizable by default.
  2179.   return (sysCall_2(_fnum_windowSetResizable, window, (void *) trueFalse));
  2180. }
  2181.  
  2182. _X_ static inline int windowSetHasMinimizeButton(objectKey window, int trueFalse)
  2183. {
  2184.   // Proto: int kernelWindowSetHasMinimizeButton(kernelWindow *, int);
  2185.   // Desc : Tells the windowing system whether to draw a minimize button on the title bar of the window 'window'.  'trueFalse' being non-zero means draw a minimize button.  Windows have minimize buttons by default, as long as they have a title bar.  If there is no title bar, then this function has no effect.
  2186.   return (sysCall_2(_fnum_windowSetHasMinimizeButton, window,
  2187.             (void *) trueFalse));
  2188. }  
  2189.  
  2190. _X_ static inline int windowSetHasCloseButton(objectKey window, int trueFalse)
  2191. {
  2192.   // Proto: int kernelWindowSetHasCloseButton(kernelWindow *, int);
  2193.   // Desc : Tells the windowing system whether to draw a close button on the title bar of the window 'window'.  'trueFalse' being non-zero means draw a close button.  Windows have close buttons by default, as long as they have a title bar.  If there is no title bar, then this function has no effect.
  2194.   return (sysCall_2(_fnum_windowSetHasCloseButton, window,
  2195.             (void *) trueFalse));
  2196. }
  2197.  
  2198. _X_ static inline int windowSetColors(objectKey window, color *background)
  2199. {
  2200.   // Proto: int kernelWindowSetColors(kernelWindow *, color *);
  2201.   // Desc : Set the background color of 'window'.  If 'color' is NULL, use the default.
  2202.   return (sysCall_2(_fnum_windowSetColors, window, background));
  2203. }
  2204.  
  2205. _X_ static inline int windowSetVisible(objectKey window, int visible)
  2206. {
  2207.   // Proto: int kernelWindowSetVisible(kernelWindow *, int);
  2208.   // Desc : Tell the windowing system whether to make 'window' visible or not.  Non-zero 'visible' means make the window visible.  When windows are created, they are not visible by default so you can add components, do layout, set the size, etc.
  2209.   return (sysCall_2(_fnum_windowSetVisible, window, (void *) visible));
  2210. }
  2211.  
  2212. _X_ static inline void windowSetMinimized(objectKey window, int minimized)
  2213. {
  2214.   // Proto: void kernelWindowSetMinimized(kernelWindow *, int);
  2215.   // Desc : Tell the windowing system whether to make 'window' minimized or not.  Non-zero 'minimized' means make the window non-visible, but accessible via the task bar.  Zero 'minimized' means restore a minimized window to its normal, visible size.
  2216.   sysCall_2(_fnum_windowSetMinimized, window, (void *) minimized);
  2217. }
  2218.  
  2219. _X_ static inline int windowAddConsoleTextArea(objectKey window, componentParameters *params)
  2220. {
  2221.   // Proto: int kernelWindowAddConsoleTextArea(kernelWindow *, componentParameters *);
  2222.   // Desc : Add a console text area component to 'window' using the supplied componentParameters.  The console text area is where most kernel logging and error messages are sent, particularly at boot time.  Note that there is only one instance of the console text area, and thus it can only exist in one window at a time.  Destroying the window is one way to free the console area to be used in another window.
  2223.   return (sysCall_2(_fnum_windowAddConsoleTextArea, window, params));
  2224. }
  2225.  
  2226. _X_ static inline void windowRedrawArea(int xCoord, int yCoord, int width, int height)
  2227. {
  2228.   // Proto: void kernelWindowRedrawArea(int, int, int, int);
  2229.   // Desc : Tells the windowing system to redraw whatever is supposed to be in the screen area bounded by the supplied coordinates.  This might be useful if you were drawing non-window-based things (i.e., things without their own independent graphics buffer) directly onto the screen and you wanted to restore an area to its original contents.  For example, the mouse driver uses this method to erase the pointer from its previous position.
  2230.   sysCall_4(_fnum_windowRedrawArea, (void *) xCoord, (void *) yCoord,
  2231.         (void *) width, (void *) height);
  2232. }
  2233.  
  2234. _X_ static inline void windowProcessEvent(objectKey event)
  2235. {
  2236.   // Proto: void kernelWindowProcessEvent(windowEvent *);
  2237.   // Desc : Creates a window event using the supplied event structure.  This function is most often used within the kernel, particularly in the mouse and keyboard functions, to signify clicks or key presses.  It can, however, be used by external programs to create 'artificial' events.  The windowEvent structure specifies the target component and event type.
  2238.   sysCall_1(_fnum_windowProcessEvent, event);
  2239. }
  2240.  
  2241. _X_ static inline int windowComponentEventGet(objectKey key, windowEvent *event)
  2242. {
  2243.   // Proto: int kernelWindowComponentEventGet(objectKey, windowEvent *);
  2244.   // Desc : Gets a pending window event, if any, applicable to component 'key', and puts the data into the windowEvent structure 'event'.  If an event was received, the function returns a positive, non-zero value (the actual value reflects the amount of raw data read from the component's event stream -- not particularly useful to an application).  If the return value is zero, no event was pending.
  2245.   return(sysCall_2(_fnum_windowComponentEventGet, key, event));
  2246. }
  2247.  
  2248. _X_ static inline int windowTileBackground(const char *theFile)
  2249. {
  2250.   // Proto: int kernelWindowTileBackground(const char *);
  2251.   // Desc : Load the image file specified by the pathname 'theFile', and if successful, tile the image on the background root window.
  2252.   return (sysCall_1(_fnum_windowTileBackground, (void *) theFile));
  2253. }
  2254.  
  2255. _X_ static inline int windowCenterBackground(const char *theFile)
  2256. {
  2257.   // Proto: int kernelWindowCenterBackground(const char *);
  2258.   // Desc : Load the image file specified by the pathname 'theFile', and if successful, center the image on the background root window.
  2259.   return (sysCall_1(_fnum_windowCenterBackground, (void *) theFile));
  2260. }
  2261.  
  2262. _X_ static inline int windowScreenShot(image *saveImage)
  2263. {
  2264.   // Proto: int kernelWindowScreenShot(image *);
  2265.   // Desc : Get an image representation of the entire screen in the image data structure 'saveImage'.  Note that it is not necessary to allocate memory for the data pointer of the image structure beforehand, as this is done automatically.  You should, however, deallocate the data field of the image structure when you are finished with it.
  2266.   return (sysCall_1(_fnum_windowScreenShot, saveImage));
  2267. }
  2268.  
  2269. _X_ static inline int windowSaveScreenShot(const char *filename)
  2270. {
  2271.   // Proto: int kernelWindowSaveScreenShot(const char *);
  2272.   // Desc : Save a screenshot of the entire screen to the file specified by the pathname 'filename'.
  2273.   return (sysCall_1(_fnum_windowSaveScreenShot, (void *) filename));
  2274. }
  2275.  
  2276. _X_ static inline int windowSetTextOutput(objectKey key)
  2277. {
  2278.   // Proto: int kernelWindowSetTextOutput(kernelWindowComponent *);
  2279.   // Desc : Set the text output (and input) of the calling process to the object key of some window component, such as a TextArea or TextField component.  You'll need to use this if you want to output text to one of these components or receive input from one.
  2280.   return (sysCall_1(_fnum_windowSetTextOutput, key));
  2281. }
  2282.  
  2283. _X_ static inline int windowComponentSetVisible(objectKey component, int visible)
  2284. {
  2285.   // Proto: int kernelWindowComponentSetVisible(kernelWindowComponent *, int);
  2286.   // Desc : Set 'component' visible or non-visible.
  2287.   return (sysCall_2(_fnum_windowComponentSetVisible, component,
  2288.             (void *) visible));
  2289. }
  2290.  
  2291. _X_ static inline int windowComponentSetEnabled(objectKey component, int enabled)
  2292. {
  2293.   // Proto: int kernelWindowComponentSetEnabled(kernelWindowComponent *, int);
  2294.   // Desc : Set 'component' enabled or non-enabled; non-enabled components appear greyed-out.
  2295.   return (sysCall_2(_fnum_windowComponentSetEnabled, component,
  2296.             (void *) enabled));
  2297. }
  2298.  
  2299. _X_ static inline int windowComponentGetWidth(objectKey component)
  2300. {
  2301.   // Proto: int kernelWindowComponentGetWidth(kernelWindowComponent *);
  2302.   // Desc : Get the pixel width of the window component 'component'.
  2303.   return (sysCall_1(_fnum_windowComponentGetWidth, component));
  2304. }
  2305.  
  2306. _X_ static inline int windowComponentSetWidth(objectKey component, int width)
  2307. {
  2308.   // Proto: int kernelWindowComponentSetWidth(kernelWindowComponent *, int);
  2309.   // Desc : Set the pixel width of the window component 'component'
  2310.   return (sysCall_2(_fnum_windowComponentSetWidth, component, (void *) width));
  2311. }
  2312.  
  2313. _X_ static inline int windowComponentGetHeight(objectKey component)
  2314. {
  2315.   // Proto: int kernelWindowComponentGetHeight(kernelWindowComponent *);
  2316.   // Desc : Get the pixel height of the window component 'component'.
  2317.   return (sysCall_1(_fnum_windowComponentGetHeight, component));
  2318. }
  2319.  
  2320. _X_ static inline int windowComponentSetHeight(objectKey component, int height)
  2321. {
  2322.   // Proto: int kernelWindowComponentSetHeight(kernelWindowComponent *, int);
  2323.   // Desc : Set the pixel height of the window component 'component'.
  2324.   return (sysCall_2(_fnum_windowComponentSetHeight, component,
  2325.             (void *) height));
  2326. }
  2327.  
  2328. _X_ static inline int windowComponentFocus(objectKey component)
  2329. {
  2330.   // Proto: int kernelWindowComponentFocus(kernelWindowComponent *);
  2331.   // Desc : Give window component 'component' the focus of its window.
  2332.   return (sysCall_1(_fnum_windowComponentFocus, component));
  2333. }
  2334.  
  2335. _X_ static inline int windowComponentDraw(objectKey component)
  2336. {
  2337.   // Proto: int kernelWindowComponentDraw(kernelWindowComponent *)
  2338.   // Desc : Calls the window component 'component' to redraw itself.
  2339.   return (sysCall_1(_fnum_windowComponentDraw, component));
  2340. }
  2341.  
  2342. _X_ static inline int windowComponentGetData(objectKey component, void *buffer, int size)
  2343. {
  2344.   // Proto: int kernelWindowComponentGetData(kernelWindowComponent *, void *, int);
  2345.   // Desc : This is a generic call to get data from the window component 'component', up to 'size' bytes, in the buffer 'buffer'.  The size and type of data that a given component will return is totally dependent upon the type and implementation of the component.
  2346.   return (sysCall_3(_fnum_windowComponentGetData, component, buffer,
  2347.             (void *) size));
  2348. }
  2349.  
  2350. _X_ static inline int windowComponentSetData(objectKey component, void *buffer, int size)
  2351. {
  2352.   // Proto: int kernelWindowComponentSetData(kernelWindowComponent *, void *, int);
  2353.   // Desc : This is a generic call to set data in the window component 'component', up to 'size' bytes, in the buffer 'buffer'.  The size and type of data that a given component will use or accept is totally dependent upon the type and implementation of the component.
  2354.   return (sysCall_3(_fnum_windowComponentSetData, component, buffer,
  2355.             (void *) size));
  2356. }
  2357.  
  2358. _X_ static inline int windowComponentGetSelected(objectKey component, int *selection)
  2359. {
  2360.   // Proto: int kernelWindowComponentGetSelected(kernelWindowComponent *);
  2361.   // Desc : This is a call to get the 'selected' value of the window component 'component'.  The type of value returned depends upon the type of component; a list component, for example, will return the 0-based number(s) of its selected item(s).  On the other hand, a boolean component such as a checkbox will return 1 if it is currently selected.
  2362.   return (sysCall_2(_fnum_windowComponentGetSelected, component, selection));
  2363. }
  2364.  
  2365.  
  2366. _X_ static inline int windowComponentSetSelected(objectKey component, int selected)
  2367. {
  2368.   // Proto: int kernelWindowComponentSetSelected(kernelWindowComponent *, int);
  2369.   // Desc : This is a call to set the 'selected' value of the window component 'component'.  The type of value accepted depends upon the type of component; a list component, for example, will use the 0-based number to select one of its items.  On the other hand, a boolean component such as a checkbox will clear itself if 'selected' is 0, and set itself otherwise.
  2370.   return (sysCall_2(_fnum_windowComponentSetSelected, component,
  2371.             (void *) selected));
  2372. }
  2373.  
  2374. _X_ static inline objectKey windowNewButton(objectKey parent, const char *label, image *buttonImage, componentParameters *params)
  2375. {
  2376.   // Proto: kernelWindowComponent *kernelWindowNewButton(volatile void *, const char *, image *, componentParameters *);
  2377.   // Desc : Get a new button component to be placed inside the parent object 'parent', with the given component parameters, and with the (optional) label 'label', or the (optional) image 'buttonImage'.  Either 'label' or 'buttonImage' can be used, but not both.
  2378.   return ((objectKey) sysCall_4(_fnum_windowNewButton, parent, (void *) label,
  2379.                 buttonImage, params));
  2380. }
  2381.  
  2382. _X_ static inline objectKey windowNewCanvas(objectKey parent, int width, int height, componentParameters *params)
  2383. {
  2384.   // Proto: kernelWindowComponent *kernelWindowNewCanvas(volatile void *, int, int, componentParameters *);
  2385.   // Desc : Get a new canvas component, to be placed inside the parent object 'parent', using the supplied width and height, with the given component parameters.  Canvas components are areas which will allow drawing operations, for example to show line drawings or unique graphical elements.
  2386.   return ((objectKey) sysCall_4(_fnum_windowNewCanvas, parent,
  2387.                 (void *) width, (void *) height, params));
  2388. }
  2389.  
  2390. _X_ static inline objectKey windowNewCheckbox(objectKey parent, const char *text, componentParameters *params)
  2391. {
  2392.   // Proto: kernelWindowComponent *kernelWindowNewCheckbox(volatile void *, const char *, componentParameters *);
  2393.   // Desc : Get a new checkbox component, to be placed inside the parent object 'parent', using the accompanying text 'text', and with the given component parameters.
  2394.   return ((objectKey) sysCall_3(_fnum_windowNewCheckbox, parent, (void *) text,
  2395.                 params));
  2396. }
  2397.  
  2398.  
  2399. _X_ static inline objectKey windowNewContainer(objectKey parent, const char *name, componentParameters *params)
  2400. {
  2401.   // Proto: kernelWindowComponent *kernelWindowNewContainer(volatile void *, const char *, componentParameters *);
  2402.   // Desc : Get a new container component, to be placed inside the parent object 'parent', using the name 'name', and with the given component parameters.  Containers are useful for layout when a simple grid is not sufficient.  Each container has its own internal grid layout (for components it contains) and external grid parameters for placing it inside a window or another container.  Containers can be nested arbitrarily.  This allows limitless control over a complex window layout.
  2403.   return ((objectKey) sysCall_3(_fnum_windowNewContainer, parent,
  2404.                 (void *) name, params));
  2405. }
  2406.  
  2407. _X_ static inline objectKey windowNewIcon(objectKey parent, image *iconImage, const char *label, componentParameters *params)
  2408. {
  2409.   // Proto: kernelWindowComponent *kernelWindowNewIcon(volatile void *, image *, const char *, const char *, componentParameters *);
  2410.   // Desc : Get a new icon component to be placed inside the parent object 'parent', using the image data structure 'iconImage' and the label 'label', and with the given component parameters 'params'.
  2411.   return ((objectKey) sysCall_4(_fnum_windowNewIcon, parent, iconImage,
  2412.                 (void *) label, params));
  2413. }
  2414.  
  2415. _X_ static inline objectKey windowNewImage(objectKey parent, image *baseImage, drawMode mode, componentParameters *params)
  2416. {
  2417.   // Proto: kernelWindowComponent *kernelWindowNewImage(volatile void *, image *, drawMode, componentParameters *);
  2418.   // Desc : Get a new image component to be placed inside the parent object 'parent', using the image data structure 'baseImage', and with the given component parameters 'params'.
  2419.   return ((objectKey) sysCall_4(_fnum_windowNewImage, parent, baseImage,
  2420.                 (void *) mode, params));
  2421. }
  2422.  
  2423. _X_ static inline objectKey windowNewList(objectKey parent, windowListType type, int rows, int columns, int multiple, listItemParameters *items, int numItems, componentParameters *params)
  2424. {
  2425.   // Proto: kernelWindowComponent *kernelWindowNewList(volatile void *, windowListType, int, int, int, listItemParameters *, int, componentParameters *);
  2426.   // Desc : Get a new window list component to be placed inside the parent object 'parent', using the component parameters 'params'.  'type' specifies the type of list (see <sys/window.h> for possibilities), 'rows' and 'columns' specify the size of the list and layout of the list items, 'multiple' allows multiple selections if non-zero, and 'items' is an array of 'numItems' list item parameters.
  2427.   return ((objectKey) sysCall_8(_fnum_windowNewList, parent, (void *) type,
  2428.                 (void *) rows, (void *) columns,
  2429.                 (void *) multiple, items, (void *) numItems,
  2430.                 params));
  2431. }
  2432.  
  2433. _X_ static inline objectKey windowNewListItem(objectKey parent, listItemParameters *item, componentParameters *params)
  2434. {
  2435.   // Proto: kernelWindowComponent *kernelWindowNewListItem(volatile void *, windowListType, listItemParameters *, componentParameters *);
  2436.   // Desc : Get a new list item component to be placed inside the parent object 'parent', using the list item parameters 'item', and the component parameters 'params'.
  2437.   return ((objectKey) sysCall_3(_fnum_windowNewListItem, parent, item,
  2438.                 params));
  2439. }
  2440.  
  2441. _X_ static inline objectKey windowNewMenu(objectKey parent, const char *name, componentParameters *params)
  2442. {
  2443.   // Proto: kernelWindowComponent *kernelWindowNewMenu(volatile void *, const char *, componentParameters *);
  2444.   // Desc : Get a new menu component to be placed inside the parent object 'parent', using the name 'name' (which will be the header of the menu) and the component parameters 'params', and with the given component parameters 'params'.  A menu component is an instance of a container, typically contains menu item components, and is typically added to a menu bar component.
  2445.   return ((objectKey) sysCall_3(_fnum_windowNewMenu, parent, (void *) name,
  2446.                 params));
  2447. }
  2448.  
  2449. _X_ static inline objectKey windowNewMenuBar(objectKey parent, componentParameters *params)
  2450. {
  2451.   // Proto: kernelWindowComponent *kernelWindowNewMenuBar(volatile void *, componentParameters *);
  2452.   // Desc : Get a new menu bar component to be placed inside the parent object 'parent', using the component parameters 'params'.  A menu bar component is an instance of a container, and typically contains menu components.
  2453.   return ((objectKey) sysCall_2(_fnum_windowNewMenuBar, parent, params));
  2454. }
  2455.  
  2456. _X_ static inline objectKey windowNewMenuItem(objectKey parent, const char *text, componentParameters *params)
  2457. {
  2458.   // Proto: kernelWindowComponent *kernelWindowNewMenuItem(volatile void *, const char *, componentParameters *);
  2459.   // Desc : Get a new menu item component to be placed inside the parent object 'parent', using the string 'text' and the component parameters 'params'.  A menu item  component is typically added to menu components, which are in turn added to menu bar components.
  2460.   return ((objectKey) sysCall_3(_fnum_windowNewMenuItem, parent, (void *) text,
  2461.                 params));
  2462. }
  2463.  
  2464. _X_ static inline objectKey windowNewPasswordField(objectKey parent, int columns, componentParameters *params)
  2465. {
  2466.   // Proto: kernelWindowComponent *kernelWindowNewPasswordField(volatile void *, int, componentParameters *);
  2467.   // Desc : Get a new password field component to be placed inside the parent object 'parent', using 'columns' columns and the component parameters 'params'.  A password field component is a special case of a text field component, and behaves the same way except that typed characters are shown as asterisks (*).
  2468.   return ((objectKey) sysCall_3(_fnum_windowNewPasswordField, parent,
  2469.                 (void *) columns, params));
  2470. }
  2471.  
  2472. _X_ static inline objectKey windowNewProgressBar(objectKey parent, componentParameters *params)
  2473. {
  2474.   // Proto: kernelWindowComponent *kernelWindowNewProgressBar(volatile void *, componentParameters *);
  2475.   // Desc : Get a new progress bar component to be placed inside the parent object 'parent', using the component parameters 'params'.  Use the windowComponentSetData() function to set the percentage of progress.
  2476.   return ((objectKey) sysCall_2(_fnum_windowNewProgressBar, parent, params));
  2477. }
  2478.  
  2479. _X_ static inline objectKey windowNewRadioButton(objectKey parent, int rows, int columns, char *items[], int numItems, componentParameters *params)
  2480. {
  2481.   // Proto: kernelWindowComponent *kernelWindowNewRadioButton(volatile void *, int, int, const char **, int, componentParameters *);
  2482.   // Desc : Get a new radio button component to be placed inside the parent object 'parent', using the component parameters 'params'.  'rows' and 'columns' specify the size and layout of the items, and 'numItems' specifies the number of strings in the array 'items', which specifies the different radio button choices.  The windowComponentSetSelected() and windowComponentGetSelected() functions can be used to get and set the selected item (numbered from zero, in the order they were supplied in 'items').
  2483.   return ((objectKey) sysCall_6(_fnum_windowNewRadioButton, parent,
  2484.                 (void *) rows, (void *) columns,
  2485.                 items, (void *) numItems, params));
  2486. }
  2487.  
  2488. _X_ static inline objectKey windowNewScrollBar(objectKey parent, scrollBarType type, int width, int height, componentParameters *params)
  2489. {
  2490.   // Proto: kernelWindowComponent *kernelWindowNewScrollBar(volatile void *, scrollBarType, int, int, componentParameters *);
  2491.   // Desc : Get a new scroll bar component to be placed inside the parent object 'parent', with the scroll bar type 'type', and the given component parameters 'params'.
  2492.   return ((objectKey) sysCall_5(_fnum_windowNewScrollBar, parent,
  2493.                 (void *) type, (void *) width, (void *) height,
  2494.                 params));
  2495. }
  2496.  
  2497. _X_ static inline objectKey windowNewTextArea(objectKey parent, int columns, int rows, int bufferLines, componentParameters *params)
  2498. {
  2499.   // Proto: kernelWindowComponent *kernelWindowNewTextArea(volatile void *, int, int, int, componentParameters *);
  2500.   // Desc : Get a new text area component to be placed inside the parent object 'parent', with the given component parameters 'params'.  The 'columns' and 'rows' are the visible portion, and 'bufferLines' is the number of extra lines of scrollback memory.  If 'font' is NULL, the default font will be used.
  2501.   return ((objectKey) sysCall_5(_fnum_windowNewTextArea, parent,
  2502.                 (void *) columns, (void *) rows,
  2503.                 (void *) bufferLines, params));
  2504. }
  2505.  
  2506. _X_ static inline objectKey windowNewTextField(objectKey parent, int columns, componentParameters *params)
  2507. {
  2508.   // Proto: kernelWindowComponent *kernelWindowNewTextField(volatile void *, int, componentParameters *);
  2509.   // Desc : Get a new text field component to be placed inside the parent object 'parent', using the number of columns 'columns' and with the given component parameters 'params'.  Text field components are essentially 1-line 'text area' components.  If the params 'font' is NULL, the default font will be used.
  2510.   return ((objectKey) sysCall_3(_fnum_windowNewTextField, parent,
  2511.                 (void *) columns, params));
  2512. }
  2513.  
  2514. _X_ static inline objectKey windowNewTextLabel(objectKey parent, const char *text, componentParameters *params)
  2515. {
  2516.   // Proto: kernelWindowComponent *kernelWindowNewTextLabel(volatile void *, const char *, componentParameters *);
  2517.   // Desc : Get a new text labelComponent to be placed inside the parent object 'parent', with the given component parameters 'params', and using the text string 'text'.  If the params 'font' is NULL, the default font will be used.
  2518.   return ((objectKey) sysCall_3(_fnum_windowNewTextLabel, parent,
  2519.                 (void *) text, params));
  2520. }
  2521.  
  2522.  
  2523. _X_ static inline void windowDebugLayout(objectKey window)
  2524. {
  2525.   // Proto: void kernelWindowDebugLayout(kernelWindow *);
  2526.   // Desc : This function draws grid boxes around all the grid cells containing components (or parts thereof)
  2527.   sysCall_1(_fnum_windowDebugLayout, window);
  2528. }
  2529.  
  2530.  
  2531. //
  2532. // User functions
  2533. //
  2534.  
  2535. _X_ static inline int userAuthenticate(const char *name, const char *password)
  2536. {
  2537.   // Proto: int kernelUserAuthenticate(const char *, const char *);
  2538.   // Desc : Given the user 'name', return 0 if 'password' is the correct password.
  2539.   return (sysCall_2(_fnum_userAuthenticate, (void *) name, (void *) password));
  2540. }
  2541.  
  2542. _X_ static inline int userLogin(const char *name, const char *password)
  2543. {
  2544.   // Proto: int kernelUserLogin(const char *, const char *);
  2545.   // Desc : Log the user 'name' into the system, using the password 'password'.  Calling this function requires supervisor privilege level.
  2546.   return (sysCall_2(_fnum_userLogin, (void *) name, (void *) password));
  2547. }
  2548.  
  2549. _X_ static inline int userLogout(const char *name)
  2550. {
  2551.   // Proto: int kernelUserLogout(const char *);
  2552.   // Desc : Log the user 'name' out of the system.  This can only be called by a process with supervisor privilege, or one running as the same user being logged out.
  2553.   return (sysCall_1(_fnum_userLogout, (void *) name));
  2554. }
  2555.  
  2556. _X_ static inline int userGetNames(char *buffer, unsigned bufferSize)
  2557. {
  2558.   // Proto: int kernelUserGetNames(char *, unsigned);
  2559.   // Desc : Fill the buffer 'buffer' with the names of all users, up to 'bufferSize' bytes.
  2560.   return (sysCall_2(_fnum_userGetNames, buffer, (void *) bufferSize));
  2561. }
  2562.  
  2563. _X_ static inline int userAdd(const char *name, const char *password)
  2564. {
  2565.   // Proto: int kernelUserAdd(const char *, const char *);
  2566.   // Desc : Add the user 'name' with the password 'password'
  2567.   return (sysCall_2(_fnum_userAdd, (void *) name, (void *) password));
  2568. }
  2569.  
  2570. _X_ static inline int userDelete(const char *name)
  2571. {
  2572.   // Proto: int kernelUserDelete(const char *);
  2573.   // Desc : Delete the user 'name'
  2574.   return (sysCall_1(_fnum_userDelete, (void *) name));
  2575. }
  2576.  
  2577. _X_ static inline int userSetPassword(const char *name, const char *oldPass, const char *newPass)
  2578. {
  2579.   // Proto: int kernelUserSetPassword(const char *, const char *, const char *);
  2580.   // Desc : Set the password of user 'name'.  If the calling program is not supervisor privilege, the correct old password must be supplied in 'oldPass'.  The new password is supplied in 'newPass'.
  2581.   return (sysCall_3(_fnum_userSetPassword, (void *) name, (void *) oldPass,
  2582.             (void *) newPass));
  2583. }
  2584.  
  2585. _X_ static inline int userGetPrivilege(const char *name)
  2586. {
  2587.   // Proto: int kernelUserGetPrivilege(const char *);
  2588.   // Desc : Get the privilege level of the user represented by 'name'.
  2589.   return (sysCall_1(_fnum_userGetPrivilege, (void *) name));
  2590. }
  2591.  
  2592. _X_ static inline int userGetPid(void)
  2593. {
  2594.   // Proto: int kernelUserGetPid(void);
  2595.   // Desc : Get the process ID of the current user's 'login process'.
  2596.   return (sysCall_0(_fnum_userGetPid));
  2597. }
  2598.  
  2599. _X_ static inline int userSetPid(const char *name, int pid)
  2600. {
  2601.   // Proto: int kernelUserSetPid(const char *, int);
  2602.   // Desc : Set the login PID of user 'name' to 'pid'.  This is the process that gets killed when the user indicates that they want to logout.  In graphical mode this will typically be the PID of the window shell pid, and in text mode it will be the PID of the login VSH shell.
  2603.   return (sysCall_2(_fnum_userSetPid, (void *) name, (void *) pid));
  2604. }
  2605.  
  2606. _X_ static inline int userFileAdd(const char *passFile, const char *userName, const char *password)
  2607. {
  2608.   // Proto: int kernelUserFileAdd(const char *, const char *, const char *);
  2609.   // Desc : Add a user to the designated password file, with the given name and password.  This can only be done by a privileged user.
  2610.   return (sysCall_3(_fnum_userFileAdd, (void *) passFile, (void *) userName,
  2611.             (void *) password));
  2612. }
  2613.  
  2614. _X_ static inline int userFileDelete(const char *passFile, const char *userName)
  2615. {
  2616.   // Proto: int kernelUserFileDelete(const char *, const char *);
  2617.   // Desc : Remove a user from the designated password file.  This can only be done by a privileged user
  2618.   return (sysCall_2(_fnum_userFileDelete, (void *) passFile,
  2619.             (void *) userName));
  2620. }
  2621.  
  2622. _X_ static inline int userFileSetPassword(const char *passFile, const char *userName, const char *oldPass, const char *newPass)
  2623. {
  2624.   // Proto: int kernelUserFileSetPassword(const char *, const char *, const char *, const char *);
  2625.   // Desc : Set the password of user 'userName' in the designated password file.  If the calling program is not supervisor privilege, the correct old password must be supplied in 'oldPass'.  The new password is supplied in 'newPass'.
  2626.   return (sysCall_4(_fnum_userFileSetPassword, (void *) passFile,
  2627.             (void *) userName, (void *) oldPass, (void *) newPass));
  2628. }
  2629.  
  2630.  
  2631. //
  2632. // Network functions
  2633. //
  2634.  
  2635. _X_ static inline int networkDeviceGetCount(void)
  2636. {
  2637.   // Proto: int kernelNetworkDeviceGetCount(void);
  2638.   // Desc: Returns the count of network devices
  2639.   return (sysCall_0(_fnum_networkDeviceGetCount));
  2640. }
  2641.  
  2642. _X_ static inline int networkDeviceGet(const char *name, networkDevice *dev)
  2643. {
  2644.   // Proto: int kernelNetworkDeviceGet(int, networkDevice *);
  2645.   // Desc: Returns the user-space portion of the requested (by 'name') network device in 'dev'.
  2646.   return (sysCall_2(_fnum_networkDeviceGet, (char *) name, dev));
  2647. }
  2648.  
  2649. _X_ static inline int networkInitialized(void)
  2650. {
  2651.   // Proto: int kernelNetworkInitialized(void);
  2652.   // Desc: Returns 1 if networking is currently enabled.
  2653.   return (sysCall_0(_fnum_networkInitialized));
  2654. }
  2655.  
  2656. _X_ static inline int networkInitialize(void)
  2657. {
  2658.   // Proto: int kernelNetworkInitialize(void);
  2659.   // Desc: Initialize and start networking.
  2660.   return (sysCall_0(_fnum_networkInitialize));
  2661. }
  2662.  
  2663. _X_ static inline int networkShutdown(void)
  2664. {
  2665.   // Proto: int kernelNetworkShutdown(void);
  2666.   // Desc: Shut down networking.
  2667.   return (sysCall_0(_fnum_networkShutdown));
  2668. }
  2669.  
  2670. _X_ static inline objectKey networkOpen(int mode, networkAddress *address, networkFilter *filter)
  2671. {
  2672.   // Proto: kernelNetworkConnection *kernelNetworkOpen(int, networkAddress *, networkFilter *);
  2673.   // Desc: Opens a connection for network communication.  The 'type' and 'mode' arguments describe the kind of connection to make (see possiblilities in the file <sys/network.h>.  If applicable, 'address' specifies the network address of the remote host to connect to.  If applicable, the 'localPort' and 'remotePort' arguments specify the TCP/UDP ports to use.
  2674.   return ((objectKey) sysCall_3(_fnum_networkOpen, (void *) mode, address,
  2675.                 filter));
  2676. }
  2677.  
  2678. _X_ static inline int networkClose(objectKey connection)
  2679. {
  2680.   // Proto: int kernelNetworkClose(kernelNetworkConnection *);
  2681.   // Desc: Close the specified, previously-opened network connection.
  2682.   return (sysCall_1(_fnum_networkClose, connection));
  2683. }
  2684.  
  2685. _X_ static inline int networkCount(objectKey connection)
  2686. {
  2687.   // Proto: int kernelNetworkCount(kernelNetworkConnection *connection);
  2688.   // Desc: Given a network connection, return the number of bytes currently pending in the input stream
  2689.   return (sysCall_1(_fnum_networkCount, connection));
  2690. }
  2691.  
  2692. _X_ static inline int networkRead(objectKey connection, unsigned char *buffer, unsigned bufferSize)
  2693. {
  2694.   // Proto: int kernelNetworkRead(kernelNetworkConnection *, unsigned char *, unsigned);
  2695.   // Desc: Given a network connection, a buffer, and a buffer size, read up to 'bufferSize' bytes (or the number of bytes available in the connection's input stream) and return the number read.  The connection must be initiated using the networkConnectionOpen() function.
  2696.   return (sysCall_3(_fnum_networkRead, connection, buffer,
  2697.             (void *) bufferSize));
  2698. }
  2699.  
  2700. _X_ static inline int networkWrite(objectKey connection, unsigned char *buffer, unsigned bufferSize)
  2701. {
  2702.   // Proto: int kernelNetworkWrite(kernelNetworkConnection *, unsigned char *, unsigned);
  2703.   // Desc: Given a network connection, a buffer, and a buffer size, write up to 'bufferSize' bytes from 'buffer' to the connection's output.  The connection must be initiated using the networkConnectionOpen() function.
  2704.   return (sysCall_3(_fnum_networkWrite, connection, buffer,
  2705.             (void *) bufferSize));
  2706. }
  2707.  
  2708. _X_ static inline int networkPing(objectKey connection, int seqNum, unsigned char *buffer, unsigned bufferSize)
  2709. {
  2710.   // Proto: int kernelNetworkPing(kernelNetworkConnection *, int, unsigned char *, unsigned);
  2711.   // Desc: Send an ICMP "echo request" packet to the host at the network address 'destAddress', with the (optional) sequence number 'seqNum'.  The 'buffer' and 'bufferSize' arguments point to the location of data to send in the ping packet.  The content of the data is mostly irrelevant, except that it can be checked to ensure the same data is returned by the ping reply from the remote host.
  2712.   return (sysCall_4(_fnum_networkPing, connection, (void *) seqNum, buffer,
  2713.             (void *) bufferSize));
  2714. }
  2715.  
  2716.  
  2717. //
  2718. // Miscellaneous functions
  2719. //
  2720.  
  2721. _X_ static inline int fontGetDefault(objectKey *pointer)
  2722. {
  2723.   // Proto: int kernelFontGetDefault(kernelAsciiFont **);
  2724.   // Desc : Get an object key in 'pointer' to refer to the current default font.
  2725.   return (sysCall_1(_fnum_fontGetDefault, pointer));
  2726. }
  2727.  
  2728. _X_ static inline int fontSetDefault(const char *name)
  2729. {
  2730.   // Proto: int kernelFontSetDefault(const char *);
  2731.   // Desc : Set the default font for the system to the font with the name 'name'.  The font must previously have been loaded by the system, for example using the fontLoad()  function.
  2732.   return (sysCall_1(_fnum_fontSetDefault, (void *) name));
  2733. }
  2734.  
  2735. _X_ static inline int fontLoad(const char* filename, const char *fontname, objectKey *pointer, int fixedWidth)
  2736. {
  2737.   // Proto: int kernelFontLoad(const char*, const char*, kernelAsciiFont **, int);
  2738.   // Desc : Load the font from the font file 'filename', give it the font name 'fontname' for future reference, and return an object key for the font in 'pointer' if successful.  The integer 'fixedWidth' argument should be non-zero if you want each character of the font to have uniform width (i.e. an 'i' character will be padded with empty space so that it takes up the same width as, for example, a 'W' character).
  2739.   return (sysCall_4(_fnum_fontLoad, (void *) filename, (void *) fontname,
  2740.             pointer, (void *) fixedWidth));
  2741. }
  2742.  
  2743. _X_ static inline int fontGetPrintedWidth(objectKey font, const char *string)
  2744. {
  2745.   // Proto: int kernelFontGetPrintedWidth(kernelAsciiFont *, const char *);
  2746.   // Desc : Given the supplied string, return the screen width that the text will consume given the font 'font'.  Useful for placing text when using a variable-width font, but not very useful otherwise.
  2747.   return (sysCall_2(_fnum_fontGetPrintedWidth, font, (void *) string));
  2748. }
  2749.  
  2750. _X_ static inline int imageLoad(const char *filename, int width, int height, image *loadImage)
  2751. {
  2752.   // Proto: int imageLoad(const char *, int, int, image *);
  2753.   // Desc : Try to load the bitmap image file 'filename' (with the specified 'width' and 'height' if possible -- zeros indicate no preference), and if successful, save the data in the image data structure 'loadImage'.
  2754.   return (sysCall_4(_fnum_imageLoad, (void *) filename,(void *) width,
  2755.             (void *) height, loadImage));
  2756. }
  2757.  
  2758. _X_ static inline int imageSave(const char *filename, int format, image *saveImage)
  2759. {
  2760.   // Proto: int imageSave(const char *, int, image *);
  2761.   // Desc : Save the image data structure 'saveImage' using the image format 'format' to the file 'fileName'.  Image format codes are found in the file <sys/image.h>
  2762.   return (sysCall_3(_fnum_imageSave, (void *) filename, (void *) format,
  2763.             saveImage));
  2764. }
  2765.  
  2766. _X_ static inline int shutdown(int reboot, int nice)
  2767. {
  2768.   // Proto: int kernelShutdown(int, int);
  2769.   // Desc : Shut down the system.  If 'reboot' is non-zero, the system will reboot.  If 'nice' is zero, the shutdown will be orderly and will abort if serious errors are detected.  If 'nice' is non-zero, the system will go down like a kamikaze regardless of errors.
  2770.   return (sysCall_2(_fnum_shutdown, (void *) reboot, (void *) nice));
  2771. }
  2772.  
  2773. _X_ static inline const char *getVersion(char *buff, int buffSize)
  2774. {
  2775.   // Proto: const char *kernelGetVersion(char *, int);
  2776.   // Desc : Get the kernel's version string int the buffer 'buff', up to 'buffSize' bytes
  2777.   return ((const char *) sysCall_2(_fnum_getVersion, buff, (void *) buffSize));
  2778. }
  2779.  
  2780. _X_ static inline int encryptMD5(const char *in, char *out)
  2781. {
  2782.   // Proto: int kernelEncryptMD5(const char *, char *);
  2783.   // Desc : Given the input string 'in', return the encrypted numerical message digest in the buffer 'out'.
  2784.   return (sysCall_2(_fnum_encryptMD5, (void *) in, out));
  2785. }
  2786.  
  2787. _X_ static inline int lockGet(lock *getLock)
  2788. {
  2789.   // Proto: int kernelLockGet(lock *);
  2790.   // Desc : Get an exclusive lock based on the lock structure 'getLock'.
  2791.   return (sysCall_1(_fnum_lockGet, (void *) getLock));
  2792. }
  2793.  
  2794. _X_ static inline int lockRelease(lock *relLock)
  2795. {
  2796.   // Proto: int kernelLockRelease(lock *);
  2797.   // Desc : Release a lock on the lock structure 'lock' previously obtained with a call to the lockGet() function.
  2798.   return (sysCall_1(_fnum_lockRelease, (void *) relLock));
  2799. }
  2800.  
  2801. _X_ static inline int lockVerify(lock *verLock)
  2802. {
  2803.   // Proto: int kernelLockVerify(lock *);
  2804.   // Desc : Verify that a lock on the lock structure 'verLock' is still valid.  This can be useful for retrying a lock attempt if a previous one failed; if the process that was previously holding the lock has failed, this will release the lock.
  2805.   return (sysCall_1(_fnum_lockVerify, (void *) verLock));
  2806. }
  2807.  
  2808. _X_ static inline int variableListCreate(variableList *list)
  2809. {
  2810.   // Proto: int kernelVariableListCreate(variableList *);
  2811.   // Desc : Set up a new variable list structure.
  2812.   return (sysCall_1(_fnum_variableListCreate, list));
  2813. }
  2814.   
  2815. _X_ static inline int variableListDestroy(variableList *list)
  2816. {
  2817.   // Proto: int kernelVariableListDestroy(variableList *);
  2818.   // Desc : Deallocate a variable list structure previously allocated by a call to variableListCreate() or configurationReader()
  2819.   return (sysCall_1(_fnum_variableListDestroy, list));
  2820. }
  2821.  
  2822. _X_ static inline int variableListGet(variableList *list, const char *var, char *buffer, unsigned buffSize)
  2823. {
  2824.   // Proto: int kernelVariableListGet(variableList *, const char *, char *, unsigned);
  2825.   // Desc : Get the value of the variable 'var' from the variable list 'list' in the buffer 'buffer', up to 'buffSize' bytes.
  2826.   return (sysCall_4(_fnum_variableListGet, list, (void *) var, buffer,
  2827.             (void *) buffSize));
  2828. }
  2829.  
  2830. _X_ static inline int variableListSet(variableList *list, const char *var, const char *value)
  2831. {
  2832.   // Proto: int kernelVariableListSet(variableList *, const char *, const char *);
  2833.   // Desc : Set the value of the variable 'var' to the value 'value'.
  2834.   return (sysCall_3(_fnum_variableListSet, list, (void *) var,
  2835.             (void *) value));
  2836. }
  2837.  
  2838. _X_ static inline int variableListUnset(variableList *list, const char *var)
  2839. {
  2840.   // Proto: int kernelVariableListUnset(variableList *, const char *);
  2841.   // Desc : Remove the variable 'var' from the variable list 'list'.
  2842.   return (sysCall_2(_fnum_variableListUnset, list, (void *) var));
  2843. }
  2844.  
  2845. _X_ static inline int configurationReader(const char *fileName, variableList *list)
  2846. {
  2847.   // Proto: int kernelConfigurationReader(const char *, variableList *);
  2848.   // Desc : Read the contents of the configuration file 'fileName', and return the data in the variable list structure 'list'.  Configuration files are simple properties files, consisting of lines of the format "variable=value"
  2849.   return (sysCall_2(_fnum_configurationReader, (void *) fileName, list));
  2850. }
  2851.  
  2852. _X_ static inline int configurationWriter(const char *fileName, variableList *list)
  2853. {
  2854.   // Proto: int kernelConfigurationWriter(const char *, variableList *);
  2855.   // Desc : Write the contents of the variable list 'list' to the configuration file 'fileName'.  Configuration files are simple properties files, consisting of lines of the format "variable=value".  If the configuration file already exists, the configuration writer will attempt to preserve comment lines (beginning with '#') and formatting whitespace.
  2856.   return (sysCall_2(_fnum_configurationWriter, (void *) fileName, list));
  2857. }
  2858.  
  2859. _X_ static inline int keyboardGetMaps(char *buffer, unsigned size)
  2860. {
  2861.   // Proto: int kernelKeyboardGetMaps(char *, unsigned);
  2862.   // Desc : Get a listing of the names of all available keyboard mappings.  The buffer is filled up to 'size' bytes with descriptive names, such as "English (UK)".  Each string is NULL-terminated, and the return value of the call is the number of strings copied.  The first string returned is the current map.
  2863.   return (sysCall_2(_fnum_keyboardGetMaps, buffer, (void *) size));
  2864. }
  2865.  
  2866. _X_ static inline int keyboardSetMap(const char *name)
  2867. {
  2868.   // Proto: int kernelKeyboardSetMap(const char *);
  2869.   // Desc : Set the keyboard mapping to the supplied 'name'.  The normal procedure would be to first call the keyboardGetMaps() function, get the list of supported mappings, and then call this function with one of those names.  Only a name returned by the keyboardGetMaps function is valid in this scenario.
  2870.   return (sysCall_1(_fnum_keyboardSetMap, (void *) name));
  2871. }
  2872.  
  2873. _X_ static inline int deviceTreeGetCount(void)
  2874. {
  2875.   // Proto: int kernelDeviceTreeGetCount(void);
  2876.   // Desc : Returns the number of devices in the kernel's device tree.
  2877.   return (sysCall_0(_fnum_deviceTreeGetCount));
  2878. }
  2879.  
  2880. _X_ static inline int deviceTreeGetRoot(device *rootDev)
  2881. {
  2882.   // Proto: int kernelDeviceTreeGetRoot(device *);
  2883.   // Desc : Returns the user-space portion of the device tree root device in the structure 'rootDev'.
  2884.   return (sysCall_1(_fnum_deviceTreeGetRoot, rootDev));
  2885. }
  2886.  
  2887. _X_ static inline int deviceTreeGetChild(device *parentDev, device *childDev)
  2888. {
  2889.   // Proto: int kernelDeviceTreeGetChild(device *, device *);
  2890.   // Desc : Returns the user-space portion of the first child device of 'parentDev' in the structure 'childDev'.
  2891.   return (sysCall_2(_fnum_deviceTreeGetChild, parentDev, childDev));
  2892. }
  2893.  
  2894. _X_ static inline int deviceTreeGetNext(device *siblingDev)
  2895. {
  2896.   // Proto: int kernelDeviceTreeGetNext(device *);
  2897.   // Desc : Returns the user-space portion of the next sibling device of the supplied device 'siblingDev' in the same data structure.
  2898.   return (sysCall_1(_fnum_deviceTreeGetNext, siblingDev));
  2899. }
  2900.  
  2901. _X_ static inline int mouseLoadPointer(const char *pointerName, const char *fileName)
  2902. {
  2903.   // Proto: int kernelMouseLoadPointer(const char *, const char *)
  2904.   // Desc : Tells the mouse driver code to load the mouse pointer 'pointerName' from the file 'fileName'.
  2905.   return (sysCall_2(_fnum_mouseLoadPointer, (char *) pointerName,
  2906.             (char *) fileName));
  2907. }
  2908.  
  2909. _X_ static inline int mouseSwitchPointer(const char *pointerName)
  2910. {
  2911.   // Proto: int kernelMouseSwitchPointer(const char *)
  2912.   // Desc : Tells the mouse driver code to switch to the mouse pointer with the given name (as specified by the pointer name argument to mouseLoadPointer).
  2913.   return (sysCall_1(_fnum_mouseSwitchPointer, (char *) pointerName));
  2914. }
  2915.  
  2916. #define _API_H
  2917. #endif
  2918.